MCPcopy Index your code
hub / github.com/pydata/xarray / data

Method data

xarray/core/variable.py:441–465  ·  view source on GitHub ↗

The Variable's data as an array. The underlying array type (e.g. dask, sparse, pint) is preserved. See Also -------- Variable.to_numpy Variable.as_numpy Variable.values

(self)

Source from the content-addressed store, hash-verified

439
440 @property
441 def data(self):
442 """
443 The Variable's data as an array. The underlying array type
444 (e.g. dask, sparse, pint) is preserved.
445
446 See Also
447 --------
448 Variable.to_numpy
449 Variable.as_numpy
450 Variable.values
451 """
452 if isinstance(self._data, PandasExtensionArray):
453 duck_array = self._data.array
454 elif isinstance(self._data, indexing.ExplicitlyIndexed):
455 duck_array = self._data.get_duck_array()
456 elif is_duck_array(self._data):
457 duck_array = self._data
458 else:
459 duck_array = self.values
460 if isinstance(duck_array, PandasExtensionArray):
461 # even though PandasExtensionArray is a duck array,
462 # we should not return the PandasExtensionArray wrapper,
463 # and instead return the underlying data.
464 return duck_array.array
465 return duck_array
466
467 @data.setter # type: ignore[override,unused-ignore]
468 def data(self, data: T_DuckArray | np.typing.ArrayLike) -> None:

Callers

nothing calls this directly

Calls 4

is_duck_arrayFunction · 0.90
as_compatible_dataFunction · 0.85
_check_shapeMethod · 0.80
get_duck_arrayMethod · 0.45

Tested by

no test coverage detected