inv#
- skrub.selectors.inv(obj)[source]#
Invert a selector.
This selects all columns except those that are matched by the input; it is equivalent to
all() - obj
or~make_selector(obj)
. The argumentobj
can be a selector but also a column name or list of column names.Examples
>>> from skrub import selectors as s >>> import pandas as pd >>> df = pd.DataFrame( ... { ... "height_mm": [297.0, 420.0], ... "width_mm": [210.0, 297.0], ... "kind": ["A4", "A3"], ... "ID": [4, 3], ... } ... ) >>> df height_mm width_mm kind ID 0 297.0 210.0 A4 4 1 420.0 297.0 A3 3
>>> s.select(df, ['ID']) ID 0 4 1 3
>>> s.select(df, s.inv(['ID'])) height_mm width_mm kind 0 297.0 210.0 A4 1 420.0 297.0 A3
>>> s.select(df, ~s.cols('ID')) height_mm width_mm kind 0 297.0 210.0 A4 1 420.0 297.0 A3