-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
WIP/ENH: add weights kw to numeric aggregation functions #15039
Conversation
biggest API issue is should:
similarly (not implemented ATM)
e.g.
|
Current coverage is 84.77% (diff: 92.70%)
|
groupby almost all working (exception is [5], which includes the weighting column) |
I don't feel strongly either way, but for consideration - R doesn't seem to normalize weights by default, nor does numpy. In [3]: pd.Series([1, 2, 3]).mean(weights=[1, 1, 2])
Out[3]: 0.75
In [4]: np.average([1, 2, 3], weights=[1, 1, 2])
Out[4]: 2.25 R > weighted.mean(x=c(1, 2, 3), w=c(1, 1, 2))
[1] 2.25 |
so if we are going to add 'options' to weighting, then
|
For I'm assuming the current implementation (re-weighting the values) isn't what most people would expect? Although that maybe that gets into the different kinds of weights, which I don't fully understand
|
another possibility is to allow weights to take an object like this:
making this similar to what |
closing for now |
Would be nice to get this opened again! |
Agreed this would be great to have, even if just on a I've added a few weighted functions to my |
closes #10030
alt to #15031
New signatures