pynapple.core.ts_group.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:

dict

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, group = [0,1,1])
  Index    Freq. (Hz)    group
-------  ------------  -------
      0             1        0
      1             2        1
      2             4        1

This exemple shows how to group the TsGroup according to one metainfo key.

>>> newtsgroup = tsgroup.getby_category('group')
>>> newtsgroup
{0:   Index    Freq. (Hz)    group
 -------  ------------  -------
       0             1        0,
 1:   Index    Freq. (Hz)    group
 -------  ------------  -------
       1             2        1
       2             4        1}