Uh oh!
There was an error while loading. Please reload this page.
Drop multi-indexes when assigning to a multi-indexed variable - #6798
Conversation
dcherian
commented
Jul 16, 2022
- ClosesDropping a MultiIndex variable raises an error after explicit indexes refactor #6505
- Tests added
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Anderson Banihirwe <axbanihirwe@ualr.edu>
| ) | ||
| for k in idx_coord_names: | ||
| if isinstance(self._data, Dataset): | ||
| del self._data._variables[k] |
There was a problem hiding this comment.
Is there a helper function to drop "associated variables" on DataArrays and Datasets?
There was a problem hiding this comment.
Like for _update_coords(), you could implement DatasetCoordinates._drop_coords() and DataArrayCoordinates._drop_coords() and call self._drop_coords() from here?
| f"This will raise an error in the future. Use `.drop_vars({idx_coord_names!r})` before " | ||
| "assigning new coordinate values.", | ||
| DeprecationWarning, | ||
| stacklevel=4, |
There was a problem hiding this comment.
Should be 4 for assign_coords and 5 for Dataset.assign but perhaps this is OK.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Benoit Bovy <bbovy@gfz-potsdam.de>
dcherian
commented
Jul 21, 2022
Thanks @benbovy ! |
* main: (313 commits) Update whats-new Release notes for v2022.06.0 (pydata#6815) Drop multi-indexes when assigning to a multi-indexed variable (pydata#6798) Support NumPy array API (experimental) (pydata#6804) Add cumsum to DatasetGroupBy (pydata#6525) Refactor groupby binary ops code. (pydata#6789) Update DataArray.rename + docu (pydata#6665) Switch to T_DataArray and T_Dataset in concat (pydata#6784) Fix typos found by codespell (pydata#6794) Update groupby attrs tests (pydata#6787) Update map_blocks to use chunksizes property. (pydata#6776) Fix `DataArrayRolling.__iter__` with `center=True` (pydata#6744) [test-upstream] Update flox repo URL (pydata#6780) Move _infer_meta_data and _parse_size to utils (pydata#6779) Make the `sel` error more descriptive when `method` is unset (pydata#6774) Move Rolling tests to their own testing module (pydata#6777) [pre-commit.ci] pre-commit autoupdate (pydata#6773) move da and ds fixtures to conftest.py (pydata#6730) Bump EnricoMi/publish-unit-test-result-action from 1 to 2 (pydata#6770) Type shape methods (pydata#6767) ...
The `DeprecationWarning` is ignored by default for `.assign_coords` due to the stacklevel (pydata#6798 (comment)) Use `FutureWarning` instead to show the warning for both `.assign` and `.assign_coords`.