pynapple.TsGroup.get_info#

TsGroup.get_info(key)[source]#

Returns metadata based on metadata column name or index.

If the metadata name does not contain special nor overlaps with class attributes, it can also be accessed as an attribute.

If the metadata name does not overlap with class-reserved keys, it can also be accessed as a key.

Parameters:

key

  • str: metadata column name or metadata index (for TsdFrame with string column names)

  • list of str: multiple metadata column names

Returns:

The metadata information based on the key provided.

Return type:

dict or np.array or Any (for single location)

Raises:

IndexError – If the metadata index is not found.

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'),
... }
>>> metadata = {"l1": [1, 2, 3], "l2": ["x", "x", "y"]}
>>> tsgroup = nap.TsGroup(tmp,metadata=metadata)
>>> print(tsgroup)
  Index     rate    l1  l2
-------  -------  ----  ----
      0  0.66722     1  x
      1  1.33445     2  x
      2  4.00334     3  y

To access a single metadata column:

>>> tsgroup.get_info("l1")
array([1, 2, 3])

To access multiple metadata columns:

>>> tsgroup.get_info(["l1", "l2"])
     l1    l2
0    1     x
1    2     x
2    3     y

To access metadata as a key:

>>> tsgroup["l1"]
array([1, 2, 3])

Multiple metadata columns can be accessed as keys:

>>> tsgroup[["l1", "l2"]]
     l1    l2
0    1     x
1    2     x
2    3     y