Other
Other common tabular operations
Cast
Cast(self, inputs, dtype)
A step for casting selected columns to a specific dtype.
Parameters
Name | Type | Description | Default |
---|---|---|---|
inputs |
SelectionType | A selection of columns to cast. | required |
dtype |
dt.DataType | type[dt.DataType] | str | The dtype to cast to. May be a dtype instance, class, or a string representation of one. | required |
Examples
>>> import ibis_ml as ml
Cast all numeric columns to float64
>>> step = ml.Cast(ml.numeric(), "float64")
Cast specific columns to int64 by name
>>> step = ml.Cast(["x", "y"], "int64")
Drop
Drop(self, inputs)
A step for dropping selected columns from the output.
Parameters
Name | Type | Description | Default |
---|---|---|---|
inputs |
SelectionType | A selection of columns to drop. | required |
Examples
>>> import ibis_ml as ml
Drop all non-numeric columns
>>> step = ml.Drop(~ml.numeric())
Drop specific columns by name
>>> step = ml.Drop(["x", "y"])
MutateAt
MutateAt(self, inputs, expr=None, /, **named_exprs)
A step for mutating a selection of columns.
Parameters
Name | Type | Description | Default |
---|---|---|---|
inputs |
SelectionType | A selection of columns to use as inputs to expr /named_exprs . |
required |
expr |
Callable[[ir.Column], ir.Column] | Deferred | None | An optional callable (Column -> Column ) or deferred expression to apply to all columns in inputs. Output columns will have the same name as their respective inputs (effectively replacing them in the output table). |
None |
named_exprs |
Callable[[ir.Column], ir.Column] | Deferred | Named callables (Column -> Column ) or deferred expressions to apply to all columns in inputs. Output columns will be named {column}_{name} where column is the input column name and name is the expression/callable name. |
{} |
Examples
>>> import ibis_ml as ml
>>> from ibis import _
Replace all numeric columns with their absolute values.
>>> step = ml.MutateAt(ml.numeric(), _.abs())
Same as the above, but instead create new columns with _abs
suffixes.
>>> step = ml.MutateAt(ml.numeric(), abs=_.abs())
Mutate
Mutate(self, *exprs, **named_exprs)
A step for defining new columns with Ibis.
Parameters
Name | Type | Description | Default |
---|---|---|---|
exprs |
Callable[[ir.Table], ir.Column] | Deferred | Callables (Table -> Column ) or deferred expressions to use to define new columns in the output table. |
() |
named_exprs |
Callable[[ir.Table], ir.Column] | Deferred | Named callables (Table -> Column ) or deferred expressions to use to define new columns in the output table. |
{} |
Examples
>>> import ibis_ml as ml
>>> from ibis import _
Define a new column c
as a**2 + b**2
>>> step = ml.Mutate(c=_.a**2 + _.b**2)