Skip to content

Commit ca3e37e

Browse files
Improve some docstrings cross-referencing (see also) and error message (skrub-data#1688)
Co-authored-by: Riccardo Cappuzzo <7548232+rcap107@users.noreply.github.com>
1 parent b803d8e commit ca3e37e

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

skrub/_apply_to_cols.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
" estimators, its ``fit``, ``transform`` and ``fit_transform`` methods expect a"
1919
" single column (a pandas or polars Series) rather than a full dataframe. To apply"
2020
" this transformer to one or more columns in a dataframe, use it as a parameter in"
21-
" a ``skrub.TableVectorizer`` or ``sklearn.compose.ColumnTransformer``. In the"
22-
" ``ColumnTransformer``, pass a single column:"
23-
" ``make_column_transformer(({class_name}(), 'col_name_1'), ({class_name}(),"
24-
" 'col_name_2'))`` instead of ``make_column_transformer(({class_name}(),"
25-
" ['col_name_1', 'col_name_2']))``."
21+
" a ``skrub.ApplyToCols`` or a ``skrub.TableVectorizer``."
22+
" To apply to all columns::\n\n"
23+
" ApplyToCol({class_name}())\n\n"
24+
"To apply to selected columns::\n\n"
25+
" ApplyToCols({class_name}(), cols=['col_name_1', 'col_name_2'])"
2626
)
2727
_SINGLE_COL_PARAGRAPH = textwrap.fill(
2828
_SINGLE_COL_LINE, initial_indent=" ", subsequent_indent=" "
@@ -34,7 +34,7 @@ class RejectColumn(ValueError):
3434
"""Used by single-column transformers to indicate they do not apply to a column.
3535
3636
>>> import pandas as pd
37-
>>> from skrub._to_datetime import ToDatetime
37+
>>> from skrub import ToDatetime
3838
>>> df = pd.DataFrame(dict(a=['2020-02-02'], b=[12.5]))
3939
>>> ToDatetime().fit_transform(df['a'])
4040
0 2020-02-02
@@ -337,7 +337,7 @@ class ApplyToCols(TransformerMixin, BaseEstimator):
337337
The transformer can raise ``RejectColumn`` to indicate it cannot handle a
338338
given column.
339339
340-
>>> from skrub._to_datetime import ToDatetime
340+
>>> from skrub import ToDatetime
341341
>>> df = pd.DataFrame(dict(birthday=["29/01/2024"], city=["London"]))
342342
>>> df
343343
birthday city

skrub/_drop_uninformative.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ class DropUninformative(SingleColumnTransformer):
2929
Drop columns with a fraction of missing values larger than threshold. If None,
3030
keep the column even if all its values are missing.
3131
32+
See Also
33+
--------
34+
Cleaner :
35+
A full-frame transformer (as opposed to single column) that can
36+
drop columns with missing values.
37+
DropCols : Dropping cols by name, dtypes, or general skrub selectors.
38+
3239
Notes
3340
-----
3441
A column is considered to be "uninformative" if one or more of the following

skrub/_select_cols.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class SelectCols(TransformerMixin, BaseEstimator):
1919
``str``: ``"col_name"`` is the same as ``["col_name"]``. See the
2020
:ref:`selectors<user_guide_selectors>` user guide for more info on selectors.
2121
22+
See Also
23+
--------
24+
DropCols : Dropping cols by name, dtypes, or general skrub selectors.
25+
Cleaner: Can be used to drop columns with too many NaNs.
26+
2227
Examples
2328
--------
2429
>>> import pandas as pd
@@ -109,6 +114,11 @@ class DropCols(TransformerMixin, BaseEstimator):
109114
``str``: ``"col_name"`` is the same as ``["col_name"]``. See the
110115
:ref:`selectors <user_guide_selectors>` user guide for more info on selectors.
111116
117+
See Also
118+
--------
119+
SelectCols : Selecting cols by name, dtypes, or general skrub selectors.
120+
Cleaner: Can be used to drop columns with too many nulls (or NaNs).
121+
112122
Examples
113123
--------
114124
>>> import pandas as pd

0 commit comments

Comments
 (0)