arviz_base.convert_to_dataset#

arviz_base.convert_to_dataset(obj, *, group='posterior', **kwargs)[source]#

Convert a supported object to an xarray dataset.

This function is idempotent, in that it will return xarray.Dataset functions unchanged. Raises ValueError if the desired group can not be extracted.

Note this goes through a DataTree object via convert_to_datatree. See its docstring for more details.

Parameters:
obj

A supported object to convert to InferenceData.

groupstr, default “posterior”

If obj is a dict or numpy array, assigns the resulting xarray dataset to this group.

**kwargsdict, optional

Keyword arguments passed to convert_to_datatree

Returns:
xarray.Dataset

New mutable dataset. See datatree.DataTree.to_dataset for more details.

Raises:
ValueError

If obj can’t be converted to a DataTree from which to extract the group Dataset.

See also

dict_to_dataset

Convert a dictionary of arrays to a xarray.Dataset following ArviZ conventions.