pynapple.core.ts_group.TsGroup.set_info#
- TsGroup.set_info(*args, **kwargs)[source]#
Add metadata information about the TsGroup. Metadata are saved as a DataFrame.
- Parameters:
*args – pandas.Dataframe or list of pandas.DataFrame
**kwargs – Can be either pandas.Series, numpy.ndarray, list or tuple
- Raises:
RuntimeError – Raise an error if no column labels are found when passing simple arguments, indexes are not equals for a pandas series,+ not the same length when passing numpy array.
TypeError – If some of the provided metadata could not be set.
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)
To add metadata with a pandas.DataFrame:
>>> import pandas as pd >>> structs = pd.DataFrame(index = [0,1,2], data=['pfc','pfc','ca1'], columns=['struct']) >>> tsgroup.set_info(structs) >>> tsgroup Index Freq. (Hz) struct ------- ------------ -------- 0 1 pfc 1 2 pfc 2 4 ca1
To add metadata with a pd.Series, numpy.ndarray, list or tuple:
>>> hd = pd.Series(index = [0,1,2], data = [0,1,1]) >>> tsgroup.set_info(hd=hd) >>> tsgroup Index Freq. (Hz) struct hd ------- ------------ -------- ---- 0 1 pfc 0 1 2 pfc 1 2 4 ca1 1