pynapple.TsGroup.getby_category#
- TsGroup.getby_category(key)[source]#
Return a list of TsGroup grouped by category.
- Parameters:
key (str) – One of the metainfo columns name
- Returns:
A dictionary 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={"group": [0, 1, 1]})
This exemple shows how to group the TsGroup according to one metainfo key.
>>> newtsgroup = tsgroup.getby_category('group') >>> newtsgroup[0] Index rate group ------- ------- ------- 0 0.66722 0 >>> newtsgroup[1] Index rate group ------- ------- ------- 1 1.33445 1 2 4.00334 1