ktk.TimeSeries.get_subset#
- TimeSeries.get_subset(data_keys)[source]#
Return a subset of the TimeSeries.
This method returns a TimeSeries that contains only selected data keys. The corresponding data_info keys are copied in the new TimeSeries. All events are also copied in the new TimeSeries.
- Parameters:
data_keys (str | list[str]) – The data keys to extract from the timeseries.
- Returns:
The TimeSeries, minus the unspecified data keys.
- Return type:
- Raises:
KeyError – If one or more data keys could not be found in the TimeSeries data.
See also
Example
>>> ts = ktk.TimeSeries(time = np.arange(10)) >>> ts = ts.add_data("signal1", ts.time) >>> ts = ts.add_data("signal2", ts.time**2) >>> ts = ts.add_data("signal3", ts.time**3) >>> ts.data.keys() dict_keys(['signal1', 'signal2', 'signal3'])
>>> ts2 = ts.get_subset(["signal1", "signal3"]) >>> ts2.data.keys() dict_keys(['signal1', 'signal3'])