ktk.TimeSeries.rename_event#

TimeSeries.rename_event(old_name, new_name, occurrence=None, *, in_place=False)[source]#

Rename an event occurrence or all events of a same name.

Parameters
  • old_name (str) – Name of the event to look for in the events list.

  • new_name (str) – New event name

  • occurrence (Optional[int]) – Optional. i_th occurence of the event to look for in the events list, starting at 0, where the occurrences are sorted in time. If None (default), all occurences of this event name are renamed.

  • 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 event.

Return type

TimeSeries

Example

>>> ts = ktk.TimeSeries()
>>> ts = ts.add_event(5.5, "event1")
>>> ts = ts.add_event(10.8, "event2")
>>> ts = ts.add_event(2.3, "event2")
>>> ts.events
[TimeSeriesEvent(time=5.5, name='event1'),
 TimeSeriesEvent(time=10.8, name='event2'),
 TimeSeriesEvent(time=2.3, name='event2')]
>>> ts = ts.rename_event("event2", "event3")
>>> ts.events
[TimeSeriesEvent(time=5.5, name='event1'),
 TimeSeriesEvent(time=10.8, name='event3'),
 TimeSeriesEvent(time=2.3, name='event3')]
>>> ts = ts.rename_event("event3", "event4", occurrence=0)
>>> ts.events
[TimeSeriesEvent(time=5.5, name='event1'),
 TimeSeriesEvent(time=10.8, name='event3'),
 TimeSeriesEvent(time=2.3, name='event4')]