elephant.pandas_bridge.multi_epochs_to_dataframe

elephant.pandas_bridge.multi_epochs_to_dataframe(container, parents=True, child_first=True)[source]

Convert one or more neo.Epoch objects to a pandas.DataFrame.

The objects can be any list, dict, or other iterable or mapping containing epochs, as well as any neo object that can hold epochs: neo.Block and neo.Segment. Objects are searched recursively, so the objects can be nested (such as a list of blocks).

The pandas.DataFrame object has one column for each epoch, with each element being the epoch label. columns are padded to the same length with NaN values.

The column heading is a pandas.MultiIndex with one index for each of the scalar attributes and annotations of the respective epoch. The index is a pandas.MultiIndex, with the first index being the time stamp from the epoch.times attribute and the second being the duration from the epoch.durations attribute.

Parameters:
containerlist, tuple, iterable, dict, neo Block, neo Segment

The container for the epochs to convert.

parentsbool, optional

Also include attributes and annotations from parent neo objects (if any).

child_firstbool, optional

If True (default True), values of child attributes are used over parent attributes in the event of a name conflict. If False, parent attributes are used. This parameter does nothing if parents is False.

Returns:
pandas DataFrame

A DataFrame containing the labels from container.

Notes

If the length of epoch.times, epoch.duration, and epoch.labels are not the same for any individual epoch, the longer will be truncated to the length of the shorter for that epoch. Between epochs, lengths can differ.

The index level names for epoch.times and epoch.durations are times and durations, respectively.

Attributes that contain non-scalar values are skipped. So are annotations or attributes containing a value of None.

quantity.Quantities types are incompatible with pandas, so attributes and annotations of that type are converted to a tuple where the first element is the scalar value and the second is the string representation of the units.