-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Allow drop bins when using the cut function #20947
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
Conversation
FANGOD
commented
May 4, 2018
•
edited
Loading
edited
- if cut(x, bins=[0, 1, 2, 3, 4, 5, 6, 6, 8, 8, 10], labels=False, retbins=True, right=False) will raise ValueError: You can drop duplicate edges by setting the 'duplicates' kwarg, so add 'duplicates' parameters to the cut function.
Codecov Report
@@ Coverage Diff @@
## master #20947 +/- ##
=========================================
Coverage ? 91.82%
=========================================
Files ? 153
Lines ? 49488
Branches ? 0
=========================================
Hits ? 45443
Misses ? 4045
Partials ? 0
Continue to review full report at Codecov.
|
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.
ok would need:
- a doc-strings update
- tests, see how testing is done for
qcut
Hello @FANGOD! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on May 10, 2018 at 18:27 Hours UTC |
|
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.
the doc-string is fine, but we need an actual test (checking the duplicates kw in test_tile.py), follow the pattern of how qcut is tested
also need a whatsnew entry
@@ -65,6 +65,8 @@ def cut(x, bins, right=True, labels=None, retbins=False, precision=3, | |||
The precision at which to store and display the bins labels. | |||
include_lowest : bool, default False | |||
Whether the first interval should be left-inclusive or not. | |||
duplicates : {default 'raise', 'drop'}, optional | |||
If bin edges are not unique, raise ValueError or drop non-uniques. |
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.
add a versionadded tag
add a Raises part of the doc-string
I don't know what to do. Your ci is too 666. |
pandas/core/reshape/tile.py
Outdated
@@ -65,6 +65,12 @@ def cut(x, bins, right=True, labels=None, retbins=False, precision=3, | |||
The precision at which to store and display the bins labels. | |||
include_lowest : bool, default False | |||
Whether the first interval should be left-inclusive or not. | |||
duplicates : {default 'raise', 'drop'}, optional | |||
If bin edges are not unique, raise ValueError("Bin edges must be |
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.
you dont need to show the error message here.
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.
instead add a Returns section in the doc-string, showing that a ValueError can be raised
pandas/core/reshape/tile.py
Outdated
e 4.0 | ||
dtype: float64, array([0, 2, 4, 6, 8])) | ||
|
||
``duplicates=drop`` drop non-uniques |
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.
make this a sentence
pandas/tests/test_tile.py
Outdated
|
||
|
||
class TestCut(object): | ||
|
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.
don't add a new file, put in pandas/tests/reshaping/test_tile.py
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.
Sorry, I didn't find it before.
ok linted and added a test. ping on green. |
thanks @FANGOD |
Finally. Good experience. |