pydata / pydata/xarray

Improve naming and standardize functionality of .reset_index() and .reset_coords() methods

Open
#4,366 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

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 to xarray from Pandas.

Describe the solution you'd like
One proposal is this:

  • Change the name of .reset_index() to .index_to_coords(), because it seems like this is what the method really does
  • Change the name of .reset_coords() to .coords_to_vars(), because it seems like this is what the method really does
  • Make a new method called .reset_index() that has the same function as Pandas .reset_index(), namely to make an index of ints from 0 to nrows
  • Make a new method called .reset_coords() that has an analagous function to Pandas .reset_index(), but for coords, namely to make an coordinate of ints from 0 to the length of that coordinate

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing xarray's existing .reset_index() and .reset_coords() methods, then compare their behavior with the linked Pandas .reset_index() documentation. The proposal is complete only after the naming changes and new index/coordinate-reset semantics are agreed and consistently implemented; no source files or tests are identified in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.