Skip to content

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

Closed

Conversation

debnathshoham
Copy link
Member

@debnathshoham debnathshoham commented Jul 7, 2021

Copy link
Contributor

@jreback jreback left a 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

@debnathshoham
Copy link
Member Author

debnathshoham commented Jul 7, 2021

Hi @jreback , apologies, I am new to open source contributions.
I have run the tests. Below is a screenshot. I am not very sure if (and how) my change caused these failures.

Screenshot 2021-07-07 at 8 50 43 PM

@jreback
Copy link
Contributor

jreback commented Jul 7, 2021

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.

@debnathshoham debnathshoham requested a review from jreback July 8, 2021 06:32
tm.assert_series_equal(result, expected)


def df_from_series_with_nonexact_categoricalindices_frompdcut():
Copy link
Contributor

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

@@ -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):
Copy link
Contributor

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

@jreback jreback added Bug cut cut, qcut labels Jul 8, 2021
@debnathshoham debnathshoham deleted the cut-with-duplicate-index branch July 8, 2021 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug cut cut, qcut
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: pd.cut raises with duplicated index and include_lowest=True
7 participants