tabsdata.tableframe.lazyframe.frame.TableFrame.rename#

TableFrame.rename(mapping: dict[str, str]) TableFrame[source]#

Rename columns from the TableFrame.

Parameters:

mapping – A dictionary mapping column names to their new names. The operation will fail if any specified column name does not exist.

Examples:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┐
│ i    ┆ f    │
│ ---  ┆ ---  │
│ i32  ┆ f64  │
╞══════╪══════╡
│ 1    ┆ 3.1  │
│ 2    ┆ 4.1  │
│ 3    ┆ 5.9  │
│ 4    ┆ 2.6  │
│ 5    ┆ 53.5 │
│ 6    ┆ 8.97 │
└──────┴──────┘
>>>
>>> tf.{"i": "index", "f": "amount"})
>>>
┌───────┬────────┐
│ index ┆ amount │
│ ----- ┆ ------ │
│ i32   ┆ f64    │
╞═══════╪════════╡
│ 1     ┆ 3.1    │
│ 2     ┆ 4.1    │
│ 3     ┆ 5.9    │
│ 4     ┆ 2.6    │
│ 5     ┆ 53.5   │
│ 6     ┆ 8.97   │
└───────┴────────┘