ktk.TimeSeries.rename_data#

TimeSeries.rename_data(old_data_key, new_data_key, *, in_place=False)[source]#

Rename a key in data and data_info.

Parameters
  • old_data_key (str) – Name of the current data key.

  • new_data_key (str) – New name of the data key.

  • in_place (bool) – Optional. True to modify and return the original TimeSeries. False to return a modified copy of the TimeSeries while leaving the original TimeSeries intact. Default is False.

Returns

The TimeSeries with the renamed data.

Return type

TimeSeries

Raises

KeyError – If this data key could not be found in the TimeSeries’ data attribute.

Example

>>> ts = ktk.TimeSeries()
>>> ts = ts.add_data("test", np.arange(10))
>>> ts = ts.add_data_info("test", "Unit", "m")
>>> ts.data
{'test': array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])}
>>> ts.data_info
{'test': {'Unit': 'm'}}
>>> ts = ts.rename_data("test", "signal")
>>> ts.data
{'signal': array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])}
>>> ts.data_info
{'signal': {'Unit': 'm'}}