Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Ongoing development

New Features
------------
- :meth:`TableReport.dict` now allows exporting the report data as a Python dictionary. :pr:`2188` by :user:`m4nn2609-dot <m4nn2609-dot>`.
- New methods :meth:`SkrubLearner.get_named_params` and
:meth:`SkrubLearner.set_named_params` allow getting and setting the outcomes for
choices contained in the DataOp, keyed by choice name. It provides a more
Expand Down
10 changes: 10 additions & 0 deletions skrub/_reporting/_table_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,16 @@ def json(self):
data = {k: v for k, v in self._summary.items() if k not in to_remove}
return json.dumps(data, cls=JSONEncoder)

def dict(self):
"""Get the report data in Python Dictionary format.

Returns
-------
dict :
The report data
"""
return json.loads(self.json())

def markdown(self):
"""Get the report as a Markdown string.

Expand Down
5 changes: 5 additions & 0 deletions skrub/_reporting/tests/test_table_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,3 +674,8 @@ def test_column_filters_fail(df_module, filter, expected, match):
)
with pytest.raises(expected, match=match):
TableReport(df, column_filters=filter)


def test_table_report_dict(air_quality):
report = TableReport(air_quality)
assert report.dict() == json.loads(report.json())
Loading