datascience.tables.Table.relabel

Table.relabel(column_label, new_label)[source]

Changes the label(s) of column(s) specified by column_label to labels in new_label.

Args:
column_label – (single str or array of str) The label(s) of

columns to be changed to new_label.

new_label – (single str or array of str): The label name(s)

of columns to replace column_label.

Raises:
ValueError – if column_label is not in table, or if

column_label and new_label are not of equal length.

TypeError – if column_label and/or new_label is not

str.

Returns:

Original table with new_label in place of column_label.

>>> table = Table().with_columns(
...     'points', make_array(1, 2, 3),
...     'id',     make_array(12345, 123, 5123))
>>> table.relabel('id', 'yolo')
points | yolo
1      | 12345
2      | 123
3      | 5123
>>> table.relabel(make_array('points', 'yolo'),
...   make_array('red', 'blue'))
red  | blue
1    | 12345
2    | 123
3    | 5123
>>> table.relabel(make_array('red', 'green', 'blue'),
...   make_array('cyan', 'magenta', 'yellow', 'key'))
Traceback (most recent call last):
    ...
ValueError: Invalid arguments. column_label and new_label must be of equal length.