-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Add unordered option to pandas.cut (#33141) #33480
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
b9cb99e
to
b7ca269
Compare
…ut raises error if labels are non-unique (pandas-dev#33141)
b7ca269
to
0dccd26
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.
Thanks! A few comments.
f2ba860
to
dbaf513
Compare
…ew lines. Updated docstrings (pandas-dev#33141)
dbaf513
to
55c086e
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.
lgtm, I think merging master will fix the CI failure
cc @pandas-dev/pandas-core |
ad4ce7f
to
8671b11
Compare
Updated: |
Updated: labels = Categorical(
labels,
categories=labels if len(set(labels)) == len(labels) else None,
ordered=ordered,
) instead of: labels = Categorical(
labels,
categories=labels if ordered else None,
ordered=ordered,
) since we need to also handle the case of unordered labels. We just need to avoid passing duplicates labels to categories and also raise an error when we are using |
thanks @mabelvj very nice! |
Added tests and error message when there are no labels and
ordered=False
.Issue: Pandas cut raises error if labels are non-unique (Closes #33141)
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff