ktk.TimeSeries.remove_data

ktk.TimeSeries.remove_data#

TimeSeries.remove_data(data_key, *, in_place=False)[source]#

Remove a key in data.

Parameters:
  • data_key (str) – 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 removed data.

Return type:

TimeSeries

Raises:

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

Example

>>> # Prepare a test TimeSeries with data "test"
>>> ts = ktk.TimeSeries()
>>> ts = ts.add_data("test", np.arange(10))
>>> ts = ts.add_info("test", "Unit", "m")
>>> ts
TimeSeries with attributes:
      time: array([], dtype=float64)
      data: {'test': array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])}
    events: []
      info: {'Time': {'Unit': 's'}, 'test': {'Unit': 'm'}}
>>> # Now remove data "test"
>>> ts = ts.remove_data("test")
>>> ts
TimeSeries with attributes:
      time: array([], dtype=float64)
      data: {}
    events: []
      info: {'Time': {'Unit': 's'}, 'test': {'Unit': 'm'}}