pynapple.TsGroup.getby_intervals#
- TsGroup.getby_intervals(key, bins)[source]#
Return a list of TsGroup binned.
- Parameters:
key (str) – One of the metainfo columns name
bins (numpy.ndarray or list) – The bin intervals
- Returns:
A list of TsGroup
- Return type:
Examples
>>> import pynapple as nap >>> import numpy as np >>> tmp = {0: nap.Ts(t=np.arange(0, 200), time_units='s'), ... 1: nap.Ts(t=np.arange(0, 200, 0.5), time_units='s'), ... 2: nap.Ts(t=np.arange(0, 300, 0.25), time_units='s')} >>> tsgroup = nap.TsGroup(tmp, metadata={"alpha": np.arange(3)})
This exemple shows how to bin the TsGroup according to one metainfo key.
>>> newtsgroup, bincenter = tsgroup.getby_intervals('alpha', [0, 1, 2]) >>> newtsgroup[0] Index rate alpha ------- ------- ------- 0 0.66722 0 >>> newtsgroup[1] Index rate alpha ------- ------- ------- 1 1.33445 1
By default, the function returns the center of the bins.
>>> bincenter array([0.5, 1.5])