pynapple.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]))
>>> tsgroup = tsd.to_tsgroup()
>>> tsgroup
  Index     rate
-------  -------
      0  0.66667
      1  0.33333
      2  0.33333

The reverse operation can be done with the TsGroup.to_tsd function :

>>> tsgroup.to_tsd()
Time (s)
----------  --
0            0
1            2
2            0
3            1
dtype: float64, shape: (4,)
Returns:

Grouped timestamps

Return type:

TsGroup