omnipy.components.tables.tasks
Tasks for reshaping and relabeling tabular datasets.
| FUNCTION | DESCRIPTION |
|---|---|
create_row_index_from_column |
Re-key a row-wise table by promoting one column to the row index. |
remove_columns |
Build a JSON list-of-dicts dataset using a per-item column-removal mapping. |
rename_col_names |
Rename selected column names in a row-wise table. |
transpose_columns_with_data_files |
Transpose table columns so data-file names become nested keys. |
create_row_index_from_column
create_row_index_from_column(
list_of_dicts: RowWiseTableWithColNamesModel, column_key: str
) -> ColumnWiseTableWithColNamesAndIndexModel
Re-key a row-wise table by promoting one column to the row index.
| PARAMETER | DESCRIPTION |
|---|---|
list_of_dicts
|
Table represented as a list of row mappings. |
column_key
|
Name of the column whose values become the outer row keys.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ColumnWiseTableWithColNamesAndIndexModel
|
An indexed table where each outer key is taken from |
Source code in src/omnipy/components/tables/tasks.py
remove_columns
remove_columns(
json_dataset: JsonListOfDictsDataset, column_keys_for_data_items: dict[str, list[str]]
) -> JsonListOfDictsDataset
Build a JSON list-of-dicts dataset using a per-item column-removal mapping.
| PARAMETER | DESCRIPTION |
|---|---|
json_dataset
|
Dataset containing row-wise records keyed by data item name.
TYPE:
|
column_keys_for_data_items
|
Column names to target for each named data item.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
JsonListOfDictsDataset
|
A JSON list-of-dicts dataset with the same item structure as the input. |
Source code in src/omnipy/components/tables/tasks.py
rename_col_names
rename_col_names(
data_file: RowWiseTableFirstRowAsColNamesModel, prev2new_keymap: dict[str, str]
) -> RowWiseTableFirstRowAsColNamesModel
Rename selected column names in a row-wise table.
| PARAMETER | DESCRIPTION |
|---|---|
data_file
|
Table whose rows are keyed by column name. |
prev2new_keymap
|
Mapping from existing column names to replacement names.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RowWiseTableFirstRowAsColNamesModel
|
A new table with renamed column keys. |
Source code in src/omnipy/components/tables/tasks.py
transpose_columns_with_data_files
transpose_columns_with_data_files(
dataset: TableWithColNamesDataset, exclude_cols: tuple[str]
) -> None
Transpose table columns so data-file names become nested keys.
| PARAMETER | DESCRIPTION |
|---|---|
dataset
|
Dataset of row-wise tables with column names.
TYPE:
|
exclude_cols
|
Column names to keep shared across all transposed rows.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
None
|
A JSON dataset whose top-level items are former column names. |