TableFrame.extract_as_rows
methodView source ↗
def extract_as_rows(offset: int, length: int) -> list[dict[str, Any]]
Categories: filters
Extract a slice of rows from the TableFrame as a list of dictionaries.
Each dictionary represents one row, where keys are column names and values are the corresponding cell values.
Parameters: offset (int): The starting row index of the slice. length (int): The number of rows to include in the slice.
Returns
list[dict[str, Any]]: A list of row dictionaries.
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_rows(offset=0, length=2)
[
>>>
>>> tf.extract_as_rows(offset=0, length=2)
[
{"a": "A", "b": 1},
{"a": "X", "b": 10},
]