Skip to content

Commit 94c6ef3

Browse files
authored
DOC - improving howto section on tablereport (#2060)
1 parent a5e292f commit 94c6ef3

5 files changed

Lines changed: 56 additions & 8 deletions

File tree

doc/guides/table_report/alter_appearance.rst renamed to doc/guides/table_report/01_alter_appearance.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
How to tweak the Appearance of the |TableReport|
88
------------------------------------------------
99

10-
The skrub global configuration includes various parameters that allow to tweak
10+
The skrub global configuration includes various parameters that let you tweak
1111
the HTML representation of the |TableReport|.
1212

1313
For performance reasons, the |TableReport| disables the computation of
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ It is also possible to export the raw HTML, or a HTML fragment to embed in a pag
2929
with :func:`~skrub.TableReport.html` and :func:`~skrub.TableReport.html_snippet`
3030
respectively.
3131

32-
Finally, it is possible to export the data in JSON format, which allows structured
32+
The report can be exported in JSON format, which allows structured
3333
access to the data and statistics used to build the report with
3434
:func:`~skrub.TableReport.json`.
3535

@@ -46,3 +46,16 @@ disabled directly when generating the table report.
4646
4747
tr = TableReport(df, plot_distributions=False)
4848
json_data = tr.json()
49+
50+
Finally, :func:`~skrub.TableReport.markdown` produces a shortened summary of the
51+
report in Markdown format. This summary contains the measured statistics and the
52+
associations (if measured): plots and table preview are skipped from this view.
53+
This format can be shared easily in text form, or fed to an AI agent to obtain
54+
insight about a given table.
55+
56+
.. warning::
57+
58+
No sanitization of the input data is performed, and the report includes raw data
59+
(column names and cell values). Therefore, it should not be used on untrusted data,
60+
or when the resulting summary may be too large as it could lead to security risks
61+
or performance problems.

doc/guides/table_report/finding_correlated_columns.rst renamed to doc/guides/table_report/03_finding_correlated_columns.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
.. |TableReport| replace:: :class:`~skrub.TableReport`
2+
.. |DropSimilar| replace:: :class:`~skrub.DropSimilar`
23
.. |column_associations| replace:: :func:`~skrub.column_associations`
34

45
.. _user_guide_table_report_associations:
56

6-
How to find correlated columns in a datarame
7+
How to find correlated columns in a dataframe
78
============================================
89

910
In addition to |TableReport|'s **Associations** tab, you can compute associations
@@ -13,11 +14,12 @@ associations.
1314
Reported metrics include `Cramer’s V statistic <https://en.wikipedia.org/wiki/Cram%C3%A9r%27s_V>`_
1415
and `Pearson’s Correlation Coefficient <https://en.wikipedia.org/wiki/Pearson_correlation_coefficient>`_.
1516
The result is returned as a dataframe that contains the column name and idx for the
16-
left and right table and both associations; results are sorted in descending order
17+
left and the right table, and both associations; results are sorted in descending order
1718
by Cramer’s V association.
1819

1920
This can be useful to have access to the information used in the |TableReport|
20-
for later use (e.g., to select which columns to drop).
21+
for later use (e.g., to select which columns to drop). These associations are
22+
also used by the |DropSimilar| transformer to select which columns should be dropped.
2123

2224
.. code-block::
2325
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.. |TableReport| replace:: :class:`~skrub.TableReport`
2+
3+
4+
How to define custom filters for the TableReport
5+
================================================
6+
7+
It is possible to define custom filters for the |TableReport| using either column
8+
names, or :ref:`skrub selectors <user_guide_selectors>`.
9+
10+
By defining a custom filter, it becomes easier to show and work directly on a given
11+
subset of columns.
12+
13+
For example, we might want to select only the columns whose name follows a certain
14+
pattern (here, starting with "metric"):
15+
16+
>>> import pandas as pd
17+
>>> from skrub import TableReport
18+
>>> from skrub import selectors as s
19+
>>> df = pd.DataFrame(
20+
... {"id": [1, 2, 3], "metric1": [1, 2, 3], "metric2": [4, 5, 6], "metric3": [7, 8, 9]}
21+
... )
22+
23+
Custom filters should be defined as a dictionary where the key is the name of the
24+
filter that should be displayed in the generated report, and the value is either
25+
a list of columns, the indices of the columns (first column has index 0 etc.), or
26+
a skrub selector, as shown in this example:
27+
28+
>>> filters = {"only_metrics": s.glob("metric*")}
29+
>>> report = TableReport(df, column_filters=filters)
30+
31+
Custom filters are placed at the top of the list of filters, in the "Filter columns"
32+
drop-down menu.

doc/howto.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ the :ref:`API Reference <api_ref>`.
1717
.. toctree::
1818
:maxdepth: 2
1919

20-
guides/table_report/alter_appearance.rst
21-
guides/table_report/exporting.rst
22-
guides/table_report/finding_correlated_columns.rst
20+
guides/table_report/01_alter_appearance.rst
21+
guides/table_report/02_exporting.rst
22+
guides/table_report/03_finding_correlated_columns.rst
23+
guides/table_report/04_custom_filters.rst
2324
guides/utilities/customizing_configuration.rst
2425
guides/utilities/deduplicate_categorical_data.rst
2526
guides/utilities/fetching_datasets.rst

0 commit comments

Comments
 (0)