pydata / pydata/xarray

Have a minimum observation keyword to Dataset.groupby() and DataArray.groupby() methods to remove bins with very few observations.

Open
#7,895 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

For the dataset groupby and data array groupby I often end up with a groups that have too few observations to be useful for statistics of plotting and have to go through and remove those bins before analysis or plotting.

Describe the solution you'd like

I would love to have a keyword that would let users remove bins below a certain number of observations. I usually don't want bins with 1-10 observations when plotting or doing statistics. I was thinking min_observation for each method and then just filter out bins below that number of observations.

Describe alternatives you've considered

I recognize that users can go through and filter out and skip bins with too few values during plotting or analysi, but this might be convenient.

Additional context

I have not contributed before and was thinking this might be an appropriately sized project to contribute back to xarray, but I wanted to see if I was missing something about why this isn't an option before I worked on it.

It seems like the code would be limited to the groupby code and the groupby tests.

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 groupby implementation in xarray/core/groupby.py and the Dataset.groupby() and DataArray.groupby() documentation linked in the issue. Review xarray/tests/test_groupby.py for existing group formation and filtering coverage. Done means both methods support the proposed minimum-observation behavior with tests covering bins below and above the threshold.

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.