nbytes
property errors for variable created from geopandas GeoDataframe with version 2025.04.0
#10342
Closed
5 tasks done
Labels
What happened?
I ran into this after updating from xarray 2025.03.0 to 2025.04.0. It seems that xarray has difficulty representing datasets created from a geopandas dataframe. Calling the
.to_xarray()
method on a geopandas dataframe creates an array with a customgeopandas.array.GeometryDtype
. The representer calls the.nbytes
property, which errors.What did you expect to happen?
With xarray version 2025.03.0, I get:
In this version the
.nbytes
property works with geopandas' GeometryDtype.Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
I'm not entirely sure if creating Datasets from geopandas GeoDataframes without any problems is within scope of xarray. I think inferring from this #10301 (comment) it is? Both xarray and geopandas are commonly used in the geospatial community (a comment of somebody who agrees with me: #10301 (comment)).
Environment
In this env, it doesn't work:
INSTALLED VERSIONS
commit: None
python: 3.13.3 | packaged by conda-forge | (main, Apr 14 2025, 20:31:24) [MSC v.1943 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 11
machine: AMD64
processor: Intel64 Family 6 Model 151 Stepping 2, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: ('Dutch_Netherlands', '1252')
libhdf5: None
libnetcdf: None
xarray: 2025.4.0
pandas: 2.2.3
numpy: 2.2.6
scipy: 1.15.2
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
zarr: None
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.10.3
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 80.8.0
pip: None
conda: None
pytest: None
mypy: None
IPython: 9.2.0
sphinx: None
In this env, it does work:
INSTALLED VERSIONS
commit: None
python: 3.13.3 | packaged by conda-forge | (main, Apr 14 2025, 20:31:24) [MSC v.1943 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 11
machine: AMD64
processor: Intel64 Family 6 Model 151 Stepping 2, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: ('Dutch_Netherlands', '1252')
libhdf5: None
libnetcdf: None
xarray: 2025.3.0
pandas: 2.2.3
numpy: 2.2.6
scipy: 1.15.2
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
zarr: None
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.10.3
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 80.8.0
pip: None
conda: None
pytest: None
mypy: None
IPython: 9.2.0
sphinx: None
The text was updated successfully, but these errors were encountered: