Skip to main content
Version: 1.9.1

by_dtype

def by_dtype(
*dtypes: td_DataType | PythonDataType | Iterable[td_DataType] | Iterable[PythonDataType],
) -> SelectorProxy

Categories: projection

Select all columns of the specified data type.

Examples

>>> import tabsdata.tableframe as td_tf
>>>
>>> tf = td_tf.TableFrame({
... "Id": [1, 2, 3, 4, 5, 6, 7, 8],
... "Name": ["A", "B", "C", "D", "E", "F", "G", "H"],
... "IsActive": [True, True, False, True, False, True, True, False],
... "Score": [91.0, 85.5, 78.0, 88.5, 90.0, 76.0, 82.5, 89.0]
... })

Original: ┌──────┬──────┬──────────┬───────┐ │ Id ┆ Name ┆ IsActive ┆ Score │ │ --- ┆ --- ┆ --- ┆ --- │ │ i64 ┆ str ┆ bool ┆ f64 │ ╞══════╪══════╪══════════╪═══════╡ │ 1 ┆ "A" ┆ true ┆ 91.0 │ │ 2 ┆ "B" ┆ true ┆ 85.5 │ │ 3 ┆ "C" ┆ false ┆ 78.0 │ │ 4 ┆ "D" ┆ true ┆ 88.5 │ │ 5 ┆ "E" ┆ false ┆ 90.0 │ │ 6 ┆ "F" ┆ true ┆ 76.0 │ │ 7 ┆ "G" ┆ true ┆ 82.5 │ │ 8 ┆ "H" ┆ false ┆ 89.0 │ └──────┴──────┴──────────┴───────┘

>>> tf.select(td_tf.selectors.by_dtype(td_tf.Float64))

Selected: ┌───────┐ │ Score │ │ --- │ │ f64 │ ╞═══════╡ │ 91.0 │ │ 85.5 │ │ 78.0 │ │ 88.5 │ │ 90.0 │ │ 76.0 │ │ 82.5 │ │ 89.0 │ └───────┘