arviz.InferenceData.to_dataframe#

InferenceData.to_dataframe(groups=None, filter_groups=None, include_coords=True, include_index=True, index_origin=None)[source]#

Convert InferenceData to a pandas.DataFrame following xarray naming conventions.

This returns dataframe in a “wide” -format, where each item in ndimensional array is unpacked. To access “tidy” -format, use xarray functionality found for each dataset.

In case of a multiple groups, function adds a group identification to the var name.

Data groups (“observed_data”, “constant_data”, “predictions_constant_data”) are skipped implicitly.

Raises TypeError if no valid groups are found.

Parameters
groups: str or list of str, optional

Groups where the transformation is to be applied. Can either be group names or metagroup names.

filter_groups: {None, “like”, “regex”}, optional, default=None

If None (default), interpret groups as the real group or metagroup names. If “like”, interpret groups as substrings of the real group or metagroup names. If “regex”, interpret groups as regular expressions on the real group or metagroup names. A la pandas.filter.

include_coords: bool

Add coordinate values to column name (tuple).

include_index: bool

Add index information for multidimensional arrays.

index_origin: {0, 1}, optional

Starting index for multidimensional objects. 0- or 1-based. Defaults to rcParams[“data.index_origin”].

Returns
pandas.DataFrame

A pandas DataFrame containing all selected groups of InferenceData object.