spiketools.stats.anova.create_dataframe_bins

spiketools.stats.anova.create_dataframe_bins(bin_data, other_data=None, dropna=True, dtypes=None, bin_columns=None)[source]

Create a dataframe from an array of binned data.

Parameters:
bin_data2d or 3d array

An array of data organized into pre-computed bins. If a 2d array, should be organized as [n_trials, n_bins]. If a 3d array, should be organized as [n_trials, n_xbins, n_ybins].

other_datadict, optional

Additional data columns, reflecting data per trial, to add to the dataframe. Each key should be a column label and each value should be an array of length n_trials.

dropnabool, optional, default: True

Whether to drop NaN values from the dataframe.

dtypesdict, optional

Data types to typecast columns to. Each key should be a column label, and each associated value the type to typecast to.

bin_columnslist of str, optional

Custom column labels for the bin data. If not provided, defaults to [‘bin’, ‘fr’] for 1d or [‘xbin’, ‘ybin’ ‘fr’] for 2d bins.

Returns:
dfpd.DataFrame

Constructed dataframe.

Examples

Create a dataframe from arrays representing 3 trials of firing rate across 5 spatial bins:

>>> data = np.array([[1, 2, 3, 7, 2], [4, 5, 6, 4, 1], [8, 9, 10, 9, 8]])
>>> df = create_dataframe_bins(data)