pydata / pydata/xarray

Add option to apply reduction operations also to coordinates instead of dropping them.

Open
#8,317 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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?

Applying reduction operations like .mean() to a Dataset or DataArray will remove all coordinates that have the reduced dimension.

Describe the solution you'd like

I would like a keyword argument (reduce_coords?) in the reduction method to allow for the reduction to also be applied to the coordinates.

Describe alternatives you've considered

A current solution is to promote the coordinates to variables, perform the reduction and then demote them back to coordinates, like in #1497 . But it would be nice to have a faster way of doing it, like in #3033 with keepdims=True to retain the dimensions after a reduction.

Additional context

No response

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 reading the reduction methods for Dataset and DataArray, then review the related discussions in issues #1497 and #3033. Done means a reduction option can apply the operation to coordinates instead of dropping those attached to the reduced dimension, with behavior defined for both object types.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.