diff --git a/xarray/core/variable.py b/xarray/core/variable.py index bb988392f50..8cf46c4b88a 100644 --- a/xarray/core/variable.py +++ b/xarray/core/variable.py @@ -403,8 +403,8 @@ def nbytes(self) -> int: If the underlying data array does not include ``nbytes``, estimates the bytes consumed based on the ``size`` and ``dtype``. """ - if hasattr(self.data, "nbytes"): - return self.data.nbytes + if hasattr(self._data, "nbytes"): + return self._data.nbytes else: return self.size * self.dtype.itemsize