Skip to content

Commit 7e2e5cf

Browse files
committed
shortening
1 parent 32d11ce commit 7e2e5cf

1 file changed

Lines changed: 28 additions & 24 deletions

File tree

skrub/selectors/_base.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -83,32 +83,21 @@ def all():
8383
8484
This is the most general selector, matching every column regardless of name,
8585
type, or content. It is useful as a starting point for building complex
86-
selections via operators.
86+
selections via operators, for example to select all columns except a specific
87+
subset.
8788
88-
**When to use**
89-
90-
- As a starting point for complex selections: ``s.all() & s.numeric()``
91-
- To exclude specific columns: ``s.all() - ['ID', 'index']``
92-
- To explicitly select everything (rarely needed, but more readable)
93-
- As the complement of other selectors via ``~s.some_selector()``
94-
95-
Description
96-
-----------
97-
Returns a selector that matches all columns in the dataframe. This is useful
98-
for operations that need a baseline for composition with other selectors,
99-
such as selecting all columns except those matching a pattern.
89+
Selectors can be combined by using set operators.
10090
10191
See Also
10292
--------
10393
inv : Select all columns except those matched by a selector
104-
cols : Select columns by explicit name
105-
make_selector : Convert a selector, name, or list to a selector
94+
cols : Select columns by exact name
10695
10796
Notes
10897
-----
10998
110-
Operator combinations
111-
~~~~~~~~~~~~~~~~~~~~~
99+
Selectors can be combined by using set operators:
100+
112101
- ``s.all() & s.numeric()`` → All numeric columns
113102
- ``s.all() - 'ID'`` → All except 'ID'
114103
- ``s.all() & s.glob('*_mm')`` → All columns matching pattern
@@ -155,7 +144,23 @@ def all():
155144

156145

157146
def cols(*columns):
158-
"""Select columns by name.
147+
"""Select columns by exact name.
148+
149+
This selector matches columns whose names are explicitly listed. It is useful
150+
for selecting a specific subset of columns, especially when combined with
151+
other selectors. For example, to select all numeric columns except for a column
152+
named "ID".
153+
154+
See Also
155+
--------
156+
inv : Select all columns except those matched by a selector
157+
all : Select all columns
158+
159+
Notes
160+
-----
161+
Selectors can be combined by using set operators:
162+
163+
- ``s.all() - s.cols('ID')`` → All except 'ID'
159164
160165
Examples
161166
--------
@@ -218,6 +223,10 @@ def inv(obj):
218223
equivalent to ``all() - obj`` or ``~make_selector(obj)``. The argument
219224
``obj`` can be a selector but also a column name or list of column names.
220225
226+
See Also
227+
--------
228+
all : Select all columns
229+
221230
Examples
222231
--------
223232
>>> from skrub import selectors as s
@@ -255,7 +264,7 @@ def inv(obj):
255264

256265

257266
def make_selector(obj):
258-
"""Normalize a selector, column name, or list of names into a ``Selector``
267+
"""Normalize a selector, column name, or list of names into a ``Selector``\
259268
object.
260269
261270
This function serves as the gateway function for all selector-accepting
@@ -279,11 +288,6 @@ def make_selector(obj):
279288
Selector
280289
A ``Selector`` object (or subclass).
281290
282-
Raises
283-
------
284-
ValueError
285-
If ``obj`` is not a selector, string, or iterable.
286-
287291
See Also
288292
--------
289293
cols : Select specific columns by name

0 commit comments

Comments
 (0)