pynapple.core.time_series.Tsd.to_tsgroup#
- Tsd.to_tsgroup()[source]#
Convert Tsd to a TsGroup by grouping timestamps with the same values. By default, the values are converted to integers.
Examples
>>> import pynapple as nap >>> import numpy as np >>> tsd = nap.Tsd(t = np.array([0, 1, 2, 3]), d = np.array([0, 2, 0, 1])) Time (s) 0.0 0 1.0 2 2.0 0 3.0 1 dtype: int64
>>> tsd.to_tsgroup() Index rate ------- ------ 0 0.67 1 0.33 2 0.33
The reverse operation can be done with the TsGroup.to_tsd function :
>>> tsgroup.to_tsd() Time (s) 0.0 0.0 1.0 2.0 2.0 0.0 3.0 1.0 dtype: float64
- Returns:
Grouped timestamps
- Return type: