skrub.Expr.skb.select#
- Expr.skb.select(cols)[source]#
Select a subset of columns.
cols
can be a column name or a list of column names, but also a skrub selector. Importantly, the exact list of columns that match the selector is stored duringfit
and then this same list of columns is selected duringtransform
.- Parameters:
- Returns:
- dataframe with only the selected columns
Examples
>>> import skrub >>> from skrub import selectors as s >>> X = skrub.X(skrub.toy_orders().X) >>> X <Var 'X'> Result: ――――――― ID product quantity date 0 1 pen 2 2020-04-03 1 2 cup 3 2020-04-04 2 3 cup 5 2020-04-04 3 4 spoon 1 2020-04-05 >>> X.skb.select(['product', 'quantity']) <Apply SelectCols> Result: ――――――― product quantity 0 pen 2 1 cup 3 2 cup 5 3 spoon 1 >>> X.skb.select(s.string()) <Apply SelectCols> Result: ――――――― product date 0 pen 2020-04-03 1 cup 2020-04-04 2 cup 2020-04-04 3 spoon 2020-04-05