arviz.InferenceData.to_dataframe#
- InferenceData.to_dataframe(groups=None, filter_groups=None, var_names=None, filter_vars=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. Raises ValueError if no data are selected.
- 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 lapandas.filter
.- var_names
str
orlist
ofstr
, optional Variables to be extracted. Prefix the variables by
~
when you want to exclude them.- filter_vars: {None, “like”, “regex”}, optional
If
None
(default), interpret var_names as the real variables names. If “like”, interpret var_names as substrings of the real variables names. If “regex”, interpret var_names as regular expressions on the real variables names. A lapandas.filter
. Like with plotting, sometimes it’s easier to subset saying what to exclude instead of what to include- 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.