pynapple.TsdFrame.restrict_info#

TsdFrame.restrict_info(key)[source]#

Restrict metadata columns to a key or list of keys.

Parameters:

key (str or list of str) – Metadata column name(s) to restrict to.

Return type:

None

Examples

>>> import pynapple as nap
>>> import numpy as np
>>> metadata = {"l1": [1, 2, 3], "l2": ["x", "x", "y"], "l3": [4, 5, 6]}
>>> tsdframe = nap.TsdFrame(t=np.arange(5), d=np.ones((5, 3)), metadata=metadata)
>>> print(tsdframe)
Time (s)    0    1    2
----------  ---  ---  ---
0.0         1.0  1.0  1.0
1.0         1.0  1.0  1.0
2.0         1.0  1.0  1.0
3.0         1.0  1.0  1.0
4.0         1.0  1.0  1.0
Metadata
----------  ---  ---  ---
l1          1    2    3
l2          x    x    y
l3          4    5    6
dtype: float64, shape: (5, 3)

To restrict to multiple metadata rows:

>>> tsdframe.restrict_info(["l2", "l3"])
>>> tsdframe
Time (s)    0    1    2
----------  ---  ---  ---
0.0         1.0  1.0  1.0
1.0         1.0  1.0  1.0
2.0         1.0  1.0  1.0
3.0         1.0  1.0  1.0
4.0         1.0  1.0  1.0
Metadata
----------  ---  ---  ---
l2          x    x    y
l3          4    5    6
dtype: float64, shape: (5, 3)

To restrict to a single metadata row:

>>> tsdframe.restrict_info("l2")
>>> tsdframe
  Time (s)    0    1    2
----------  ---  ---  ---
         0    1    1    1
         1    1    1    1
         2    1    1    1
         3    1    1    1
         4    1    1    1
Metadata
----------  ---  ---  ---
l2          x    x    y
dtype: float64, shape: (5, 3)