from_dict
- classmethod UnitsAwareDataArray.from_dict(d: Mapping[str, Any]) Self
Convert a dictionary into an xarray.DataArray
- Parameters:
d (dict) – Mapping with a minimum structure of {“dims”: […], “data”: […]}
- Returns:
obj
- Return type:
See also
DataArray.to_dict
,Dataset.from_dict
Examples
>>> d = {"dims": "t", "data": [1, 2, 3]} >>> da = xr.DataArray.from_dict(d) >>> da <xarray.DataArray (t: 3)> Size: 24B array([1, 2, 3]) Dimensions without coordinates: t
>>> d = { ... "coords": { ... "t": {"dims": "t", "data": [0, 1, 2], "attrs": {"units": "s"}} ... }, ... "attrs": {"title": "air temperature"}, ... "dims": "t", ... "data": [10, 20, 30], ... "name": "a", ... } >>> da = xr.DataArray.from_dict(d) >>> da <xarray.DataArray 'a' (t: 3)> Size: 24B array([10, 20, 30]) Coordinates: * t (t) int64 24B 0 1 2 .. attribute:: title
air temperature