to_dict
- UnitsAwareDataArray.to_dict(data: bool | Literal['list', 'array'] = 'list', encoding: bool = False) dict[str, Any]
Convert this xarray.DataArray into a dictionary following xarray naming conventions.
Converts all variables and attributes to native Python objects. Useful for converting to json. To avoid datetime incompatibility use decode_times=False kwarg in xarray.open_dataset.
- Parameters:
data (bool or {"list", "array"}, default: "list") – Whether to include the actual data in the dictionary. When set to False, returns just the schema. If set to “array”, returns data as underlying array type. If set to “list” (or True for backwards compatibility), returns data in lists of Python data types. Note that for obtaining the “list” output efficiently, use da.compute().to_dict(data=”list”).
encoding (bool, default: False) – Whether to include the Dataset’s encoding in the dictionary.
- Returns:
dict
- Return type:
See also
DataArray.from_dict
,Dataset.to_dict