-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: Require sample weights to sum to less than 1 when replace = True #61582
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
base: main
Are you sure you want to change the base?
BUG: Require sample weights to sum to less than 1 when replace = True #61582
Conversation
1281002
to
1d1f742
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, but the condition needs adjusted. Will also need a note in the whatsnew for 3.0 under the Other section.
pandas/core/sample.py
Outdated
if weight_sum > 1 and replace: | ||
raise ValueError( | ||
"Invalid weights: If `replace`=True weights must sum to less than 1" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the correct condition. See the formula in the OP of the linked issue.
pandas/core/generic.py
Outdated
When replace = True will not allow weights that add up to less | ||
than 1, to avoid biased results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When replace = True will not allow weights that add up to less | |
than 1, to avoid biased results. | |
When replace = False will not allow ``(n * max(weights) / sum(weights)) > 1``, | |
to avoid biased results. |
46f7059
to
2bc3618
Compare
2bc3618
to
e5f9a07
Compare
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.