glob#
- skrub.selectors.glob(pattern)[source]#
Select columns by name with Unix shell style ‘glob’ pattern.
Pattern matching is case-sensitive and interpreted as described in
fnmatch.fnmatchcase:* matches everything ? matches any single character [seq] matches any character in seq [!seq] matches any char not in seq
- Parameters:
- pattern
python:str A glob pattern to match column names.
- pattern
See also
regexSelect columns by name using regular expressions. Use this for complex patterns that glob cannot express.
filter_namesSelect columns based on custom name-based criteria.
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], ... } ... )
Select columns matching a pattern:
>>> s.select(df, s.glob('*_mm')) height_mm width_mm 0 297.0 210.0 1 420.0 297.0
Use character classes to match specific patterns:
>>> s.select(df, s.glob('[a-z]*_mm')) height_mm width_mm 0 297.0 210.0 1 420.0 297.0
Combine with other selectors:
>>> s.select(df, s.glob('*_mm') | s.glob('ID')) height_mm width_mm ID 0 297.0 210.0 4 1 420.0 297.0 3