elephant.pandas_bridge.epoch_to_dataframe

elephant.pandas_bridge.epoch_to_dataframe(epoch, parents=True, child_first=True)[source]

Convert a neo.core.Epoch to a pandas.DataFrame.

The pandas.DataFrame object has a single column, with each element being the epoch label from the epoch.label attribute.

The column heading is a pandas.MultiIndex with one index for each of the scalar attributes and annotations. 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:
epochneo Epoch

The Epoch 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 epoch.

Notes

If the length of epoch.times, epoch.duration, and epoch.labels are not the same, the longer will be truncated to the length of the shortest.

The index 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.