Skip to content

AttributeError accessing data_array.variable #4194

Closed
@michaelaye

Description

@michaelaye

What happened:

accessing variable attribute seems to work but also throws an AttributeError:

AttributeError: 'Variable' object has no attribute 'variable'

What you expected to happen:

According to https://xarray.pydata.org/en/stable/terminology.html all DataArrays should have "an underlying variable that can be accessed via arr.vairable", so I tried that out and got the error.

Minimal Complete Verifiable Example:

Using the example code from the docs:

data = xr.DataArray(np.random.randn(2, 3), dims=('x', 'y'), coords={'x': [10, 20]})
data.variable

Environment:
Python 3.7 on Kubuntu 20.04 using Brave browser in Jupyterlab, up-to-date conda env.

Output of xr.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.7.6 | packaged by conda-forge | (default, Jun 1 2020, 18:57:50)
[GCC 7.5.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-40-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.6
libnetcdf: 4.7.4

xarray: 0.15.1
pandas: 1.0.5
numpy: 1.18.5
scipy: 1.5.0
netCDF4: 1.5.3
pydap: None
h5netcdf: None
h5py: 2.10.0
Nio: None
zarr: None
cftime: 1.1.3
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.1.5
cfgrib: None
iris: None
bottleneck: None
dask: 2.19.0
distributed: 2.19.0
matplotlib: 3.2.2
cartopy: 0.18.0
seaborn: 0.10.1
numbagg: None
setuptools: 47.3.1.post20200616
pip: 20.1.1
conda: installed
pytest: 5.4.3
IPython: 7.16.1
sphinx: 3.1.1

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions