-
-
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
Improve naming and standardize functionality of .reset_index() and .reset_coords() methods #4366
Comments
I agree too that the behavior of those methods is currently quite counter-intuitive in some cases. There's indeed an opportunity to address that with the indexes refactor, see for example some related suggestions in those comments: #4825 (comment) and #5692 (comment). It's not easy to find good names and clear API, though. More ideas like yours @rchurt are welcome. Some comments on your proposal:
Agreed,
Pandas' Resetting to a new index of incremental integers might be useful but this means replacing the existing coordinate labels, which is not very intuitive for a method called
I'm not sure about the advantages of having a specific method over doing something like: ds["x"] = np.arange(ds.x.size) If we eventually move away from treating pandas (multi-)indexes as a special case in xarray, another suggestion would be to intentionally depart from pandas' API and have something like:
|
I am inclined to deprecate I agree that |
Is your feature request related to a problem? Please describe.
I think that the behavior of the
.reset_index()
and.reset_coords()
methods is a bit non-intuitive, especially when coming toxarray
fromPandas
.Describe the solution you'd like
One proposal is this:
.reset_index()
to.index_to_coords()
, because it seems like this is what the method really does.reset_coords()
to.coords_to_vars()
, because it seems like this is what the method really does.reset_index()
that has the same function asPandas
.reset_index()
, namely to make an index ofint
s from 0 tonrows
.reset_coords()
that has an analagous function toPandas
.reset_index()
, but forcoords
, namely to make ancoordinate
ofint
s from 0 to the length of that coordinateThe text was updated successfully, but these errors were encountered: