groupby_bins
based on quantiles
#7110
Unanswered
jonas-spaeth
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently possible
groupby_bins
allows to specifybins
either as integer (specifying the number of bins) or list (specifying the explicit interval edges). Ifbins
is an integer, the bins are automatically created such that each intervals span the same width (e.g., from 0-2, from 2-4 and 4-6), because it relies onpd.cut
.Currently not directly possible
I often need to bin data based on quantiles, i.e., in groups of the same size. This is possible using
pd.qcut
, but it is not possible using xarray, as far that I am aware?Wouldn't it be nice to be able to specify whether
groupby_bins(..., bins=3)
should create intervals of equal length or intervals such that the groups are of equal size?Here is an example:
Implementation
could be easy I guess, just using an if statement to either execute
or
Beta Was this translation helpful? Give feedback.
All reactions