-
-
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
Dataset.drop() no longer works with a set as an argument #3552
Comments
I believe a |
How about |
@dcherian - are you suggesting that @xylar change his downstream code to use Instead we should fix this bug. The docs for drop suggest that you should be able to provide a set as an input. Somehow we made that not work in the latest release. |
Yes yes I agree!
|
I'm confused. In 0.14.1,
Yes, I switched to So @rabernat and @dcherian, please clarify if I should be switching to |
I think ds = xr.Dataset({"a": ("b", [0, 1, 2]), "c": [-1, 2, 4]}, coords={"b": list("abc")})
ds.drop_vars({"a", "b"})
ds.drop_vars(["a", "b"])
ds.drop(["a", "b"]) Additionally, I think we have a documentation bug: I can't reach the documentation on |
so I guess we need to figure out why sets don't work anymore? |
Yes, I noticed that, too. I assumed it wasn't being documented anymore because it was considered deprecated. |
I apologize for this slight tangent but it's related to why we use sets in |
explicitly selecting should work like this: ds = xr.Dataset(
{"a": ("b", [0, 1, 2]), "c": ("b", [-1, 2, 4]), "d": ("b", [5, 1, 3])},
coords={"b": list("abc")},
)
variables = ["a", "d"]
ds[variables] I think |
Ah, thanks very much! I'll switch to using that syntax instead. |
|
We were using a subset_variables() function whereas it is simple to just index the dataset with the desired variables, see: pydata/xarray#3552 (comment)
the reason for |
👍 re @keewis 's point re |
This also happens with other iterables like |
MCVE Code Sample
Expected Output
Problem Description
In versions before xarray 0.14.1, the code above involving calls to
Dataset.drop()
with aset
as an argument worked as expected. With the new release, the result is an error as shown below. This is breaking backwards compatibility with our software (MPAS-Analysis).Output of
xr.show_versions()
xarray: 0.14.1
pandas: 0.25.3
numpy: 1.17.3
scipy: 1.3.2
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: 1.3.1
dask: 2.8.0
distributed: 2.8.0
matplotlib: 3.1.2
cartopy: 0.17.0
seaborn: None
numbagg: None
setuptools: 41.6.0.post20191101
pip: 19.3.1
conda: None
pytest: 5.3.0
IPython: None
sphinx: None
The text was updated successfully, but these errors were encountered: