-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
warn when updating coord.values : indexes are not updated #3470
Comments
@folmerkrikken How about @shoyer I've seen this type of code elsewhere: direct assignment to |
Should we raise an error? Is there ever a use here? |
@dcherian Yes, ds.assign_coords does work and that's what I'm using now. So can ds.assign_coords(..) be seen as the right way and changing the values inplace with ds.time.values = pd.... the wrong way? It all worked fine until changing from version 0.11.3 to 0.12.0. |
Is it already decided what the resolution should be?
|
The main problem is that when you write This happened to work in previous versions of xarray, but only because indexes always mapped directly into the data of an xarray.Variable. But I don't think this is the right pattern to continue in the future, especially because we want to do define indexes over multiple variables (e.g., for MultiIndex). I think what we probably want to do is mark variables used in indexes as having immutable data in xarray's data model, and raise an error for attempts to modify them in-place. |
How do I implement this? |
I might be wrong, but I think you should be able to implement this by overriding |
Hi, I've recently come across what it seems to be a bit annoying bug. After adding an offset to the time dimension using pd.add_offset(), the wrong times are selected when using .sel(). I've come across this behavior in recent versions of xarray, starting from 0.12. I've now worked around it by using ds.assign_coords(time = ...). I'm not sure however if this is a possible bug in Xarray or Pandas. Below a minimum working example.
MCVE Code Sample
Expected Output
Expected output is that seltime and ds.sel(time=seltime).time are the same
Output of
xr.show_versions()
xarray: 0.14.0
pandas: 0.25.2
numpy: 1.17.3
scipy: 1.3.1
netCDF4: 1.4.0
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.0.3.4
nc_time_axis: 1.1.0
PseudoNetCDF: None
rasterio: 1.0.26
cfgrib: None
iris: None
bottleneck: 1.2.1
dask: 2.3.0
distributed: None
matplotlib: 3.1.1
cartopy: 0.17.0
seaborn: 0.9.0
numbagg: None
setuptools: 41.2.0
pip: 9.0.1
conda: None
pytest: None
IPython: 7.7.0
sphinx: None
The text was updated successfully, but these errors were encountered: