🍾 Xarray is now 10 years old! 🎉



DataArray.to_dict(data='list', encoding=False)[source]#

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.

  • 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.


dict (dict)