-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Calling Dataset.mean() drops coordinates #3510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the issue and clear example @kjfergu . Agree that's not robust. Is this specific case fixed by passing
That said, we should be consistent, or raise on passing |
@max-sixty I can confirm that using Honestly, I just used axis because that's the form I'm used to passing when using various other operations that act on an array with numpy - I admittedly did not make a point to look closely at the docs for that particular case and just assumed because Interestingly, as a side note, I did initially try |
Thanks @kjfergu I think that's a fairly common 'misuse'. Solving the coords problem here doesn't solve the larger problem of an easier learning curve where xarray is helpful quickly—which likely involves using We could raise on |
I don't know of any. I didn't know it was possible! But since we don't guarantee that all DataArrays in a Dataset have the same order-of-dimensions, this is just asking for trouble. |
What about raising a warning when |
Can someone explain why we even allow axis as a valid argument? I can't think of any good reasons why we should keep it, and it's inconsistent with the API in most places I think. |
I agree with removing. We could raise an error saying |
This is a similar issue to bug #1470.
MCVE Code Sample
Output (with extra stuff snipped for brevity):
It's also worth mentioning that the data arrays contained in the dataset also loose their coordinates during this operation. I.E:
Output of
xr.show_versions()
xarray: 0.14.0
pandas: 0.25.2
numpy: 1.17.3
scipy: 1.3.1
netCDF4: 1.5.3
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.0.4.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2.7.0
distributed: None
matplotlib: 3.1.1
cartopy: None
seaborn: None
numbagg: None
setuptools: 40.8.0
pip: 19.3
conda: None
pytest: None
IPython: 7.8.0
sphinx: None
None
The text was updated successfully, but these errors were encountered: