Skip to content

Commit a835f7e

Browse files
docs: Add Summary.to_json() (#33)
1 parent adb1d3a commit a835f7e

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

diffly/summary.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,42 @@ def format(self, pretty: bool | None = None) -> str:
9595
def to_json(self, **kwargs: Any) -> str:
9696
"""Serialize this summary as a JSON string.
9797
98-
Returns:
99-
A JSON string representation of the summary data.
98+
Args:
99+
**kwargs: Additional keyword arguments passed to :func:`json.dumps`
100+
(e.g. ``indent=2`` for pretty-printing).
101+
102+
Example:
103+
.. code-block:: json
104+
105+
{
106+
"equal": false,
107+
"left_name": "left",
108+
"right_name": "right",
109+
"primary_key": ["id"],
110+
"schemas": {
111+
"left_only_names": [],
112+
"in_common": [["id", "Int64", "Int64"], ["value", "Float64", "Float64"]],
113+
"right_only_names": []
114+
},
115+
"rows": {
116+
"n_left": 3,
117+
"n_right": 3,
118+
"n_left_only": 0,
119+
"n_joined_equal": 2,
120+
"n_joined_unequal": 1,
121+
"n_right_only": 0
122+
},
123+
"columns": [
124+
{
125+
"name": "value",
126+
"match_rate": 0.667,
127+
"n_total_changes": 1,
128+
"changes": [{"old": 1.0, "new": 2.0, "count": 1, "sample_pk": [1]}]
129+
}
130+
],
131+
"sample_rows_left_only": [],
132+
"sample_rows_right_only": []
133+
}
100134
"""
101135
return self._data.to_json(**kwargs)
102136

docs/api/summary.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ Summary
1818
:toctree: _gen/
1919

2020
Summary.format
21+
Summary.to_json

0 commit comments

Comments
 (0)