Skip to main content
Version: 1.9.1

TableFrame.extract_as_columns

def extract_as_columns(offset: int, length: int) -> dict[str, list[Any]]

Categories: filters

Extract a slice of rows from the table as a column-oriented dictionary.

The result is a mapping of column names to lists of values from the selected rows.

Parameters: offset (int): The starting row index of the slice. length (int): The number of rows to include in the slice.

Returns

dict[str, list[Any]]: A dictionary where each key is a column name, and its value is a list of values from the selected slice.

Examples

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌─────┬─────┐
│ a ┆ b │
------
str ┆ i64 │
╞═════╪═════╡
│ A ┆ 1
│ X ┆ 10
│ C ┆ 3
│ D ┆ 5
│ M ┆ 9
└─────┴─────┘
>>>
>>> tf.extract_as_columns(offset=0, length=2)
{
"a": ["A", 1],
"b": ["X", 10]
}