Skip to content

xr.Dataset.drop #2994

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

Closed
markusritschel opened this issue May 28, 2019 · 1 comment · Fixed by #3028
Closed

xr.Dataset.drop #2994

markusritschel opened this issue May 28, 2019 · 1 comment · Fixed by #3028

Comments

@markusritschel
Copy link

Currently, drop throws an error if one of the labels doesn't exist. It would be nice to have a parameter in the drop method for optionally ignoring errors like in the pandas.DataFrame.
From the pandas documentation:

errors : {‘ignore’, ‘raise’}, default ‘raise’
If ‘ignore’, suppress error and only existing labels are dropped.

@shoyer
Copy link
Member

shoyer commented May 28, 2019

This sounds fine to me. Any interest in putting together a pull request? See http://xarray.pydata.org/en/stable/contributing.html for guidance.

(It might also make sense to put this in xarray's drop_dims as well, for consistency)

shoyer pushed a commit that referenced this issue Jun 20, 2019
* Add "errors" keyword argument (GH2994)

Adds an errors keyword to Dataset.drop(), Dataset.drop_dims(), and DataArray.drop() (GH2994). Consistent with pandas, the value can be either "raise" or "ignore"

* Fix quotes

* Different pandas versions raise different errors

* Error messages also vary

* Correct doc for DataArray.drop; array, not dataset

* Require errors argument to be passed with a keyword
dcherian added a commit to dcherian/xarray that referenced this issue Jun 24, 2019
* master: (31 commits)
  Add quantile method to GroupBy (pydata#2828)
  rolling_exp (nee ewm) (pydata#2650)
  Ensure explicitly indexed arrays are preserved (pydata#3027)
  add back dask-dev tests (pydata#3025)
  ENH: keepdims=True for xarray reductions (pydata#3033)
  Revert cmap fix (pydata#3038)
  Add "errors" keyword argument to drop() and drop_dims() (pydata#2994) (pydata#3028)
  More consistency checks (pydata#2859)
  Check types in travis (pydata#3024)
  Update issue templates (pydata#3019)
  Add pytest markers to avoid warnings (pydata#3023)
  Feature/merge errormsg (pydata#2971)
  More support for missing_value. (pydata#2973)
  Use flake8 rather than pycodestyle (pydata#3010)
  Pandas labels deprecation (pydata#3016)
  Pytest capture uses match, not message (pydata#3011)
  dask-dev tests to allowed failures in travis (pydata#3014)
  Fix 'to_masked_array' computing dask arrays twice (pydata#3006)
  str accessor (pydata#2991)
  fix safe_cast_to_index (pydata#3001)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants