-
-
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
clean up the API for renaming and changing dimensions / coordinates #4825
Comments
I agree it's confusing, and I find myself looking up the correct way to do something fairly frequently. I'm not sure exactly how to rationalize them though. Without thinking this through in enough detail, Does |
There's also |
How about
|
if we do 2 I think we should add a |
I think that the explicit index refactoring would be an opportunity to clarify things a bit. With no concept of a dimension coordinate/ implicit index, ideally we could have the following behavior with a clear distinction between dimensions/coordinates and indexes, following more closely the "explicit is better than implicit" principle:
This would be in an ideal world, though. More practically, I don't know how we could make a smooth transition.
|
From #4108:
I wonder if it would be better to first "reorganize" all of the existing functions: we currently have
rename
(andDataset.rename_dims
/Dataset.rename_vars
),set_coords
,reset_coords
,set_index
,reset_index
andswap_dims
, which overlap partially. For example, the code sample from #4417 works if instead ofwe use
and something similar for the code sample in #4107.
I believe we currently have these use cases (not sure if that list is complete, though):
DataArray
→rename
rename
/Dataset.rename_vars
/Dataset.rename_dims
set_coords
reset_coords
swap_dims
set_index
_
to its name (do not rename the dimension) →reset_index
set_index
reset_index
Sometimes, some of these can be emulated by combinations of others, for example:
and, with this PR:
which means that it would increase the overlap of
rename
,set_index
, andswap_dims
.In any case I think we should add a guide which explains which method to pick in which situation (or extend
howdoi
).Originally posted by @keewis in #4108 (comment)
The text was updated successfully, but these errors were encountered: