pynapple.IntervalSet.get_info#

IntervalSet.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 or metadata indices (for TsdFrame with string column names)

  • Number: metadata index (for TsGroup and IntervalSet)

  • list, np.ndarray, pd.Series: metadata index (for TsGroup and IntervalSet)

  • tuple: metadata index and column name (for TsGroup and IntervalSet)

Returns:

The metadata information based on the key provided.

Return type:

pandas.Series or pandas.DataFrame or Any (for single location)

Raises:

IndexError – If the metadata index is not found.

Examples

>>> import pynapple as nap
>>> import numpy as np
>>> times = np.array([[0, 5], [10, 12], [20, 33]])
>>> metadata = {"l1": [1, 2, 3], "l2": ["x", "x", "y"]}
>>> ep = nap.IntervalSet(tmp,metadata=metadata)

To access a single metadata column:

>>> ep.get_info("l1")
0    1
1    2
2    3
Name: l1, dtype: int64

To access multiple metadata columns:

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

To access metadata of a single index:

>>> ep.get_info(0)
rate    0.667223
l1             1
l2             x
Name: 0, dtype: object

To access metadata of multiple indices:

>>> ep.get_info([0, 1])
       rate  l1 l2
0  0.667223   1  x
1  1.334445   2  x

To access metadata of a single index and column:

>>> ep.get_info((0, "l1"))
np.int64(1)

To access metadata as an attribute:

>>> ep.l1
0    1
1    2
2    3
Name: l1, dtype: int64

To access metadata as a key:

>>> ep["l1"]
0    1
1    2
2    3
Name: l1, dtype: int64

Multiple metadata columns can be accessed as keys:

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