datascience.tables.Table.relabel¶
-
Table.
relabel
(column_label, new_label)[source]¶ Change the labels of columns specified by
column_label
to labels innew_label
.- Args:
column_label
(single str or list/array of str): The label(s) of- columns to be changed. Must be str.
new_label
(single str or list/array of str): The new label(s) ofcolumns to be changed. Must be str.
Number of elements must match number of elements in
column_label
.
- Returns:
- Original table with modified labels
>>> table = Table().with_columns([ ... 'points', (1, 2, 3), ... 'id', (12345, 123, 5123)]) >>> table.relabel('id', 'yolo') points | yolo 1 | 12345 2 | 123 3 | 5123 >>> table.relabel(['points', 'yolo'], ['red', 'blue']) red | blue 1 | 12345 2 | 123 3 | 5123 >>> table.relabel(['red', 'green', 'blue'], ['cyan', 'magenta', 'yellow', 'key']) Traceback (most recent call last): ... ValueError: Invalid arguments. column_label and new_label must be of equal length. >>> table.relabel(['red', 'blue'], ['blue', 'red']) blue | red 1 | 12345 2 | 123 3 | 5123