-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: pd.cut with duplicate index Series lowest included #42425
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
BUG: pd.cut with duplicate index Series lowest included #42425
Conversation
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.
pls always add tests for any change
Hi @jreback , apologies, I am new to open source contributions. |
we have extensive docummentation on how to do changes: https://pandas.pydata.org/pandas-docs/dev/development/index.html you need to add tests for your scenario and not break anything else. |
pandas/tests/reshape/test_cut.py
Outdated
tm.assert_series_equal(result, expected) | ||
|
||
|
||
def df_from_series_with_nonexact_categoricalindices_frompdcut(): |
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 won't execute as its not named correctly e.g. name similar to the above
pandas/core/reshape/tile.py
Outdated
@@ -421,7 +421,10 @@ def _bins_to_cuts( | |||
ids = ensure_platform_int(bins.searchsorted(x, side=side)) | |||
|
|||
if include_lowest: | |||
ids[x == bins[0]] = 1 | |||
if isinstance(x, ABCSeries): |
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.
try using
ids[np.asarray(x) == bins[0]] = 1
instead of the if/else
Co-authored-by: Jeff Reback <[email protected]>
include_lowest=True
#42185