ktk.TimeSeries.rename_data

ktk.TimeSeries.rename_data#

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

Rename a key in data.

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(time = np.arange(10))
>>> ts = ts.add_data("test", np.arange(10))
>>> ts = ts.add_info("test", "Unit", "m")
>>> ts
TimeSeries with attributes:
      time: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
      data: {'test': array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])}
    events: []
      info: {'Time': {'Unit': 's'}, 'test': {'Unit': 'm'}}
>>> ts = ts.rename_data("test", "signal")
>>> ts
TimeSeries with attributes:
      time: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
      data: {'signal': array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])}
    events: []
      info: {'Time': {'Unit': 's'}, 'test': {'Unit': 'm'}}