Skip to content

cut: documentation wrongly claims that labels=False (always) returns an ndarray of ints #51992

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
juliangilbey opened this issue Mar 15, 2023 · 2 comments · Fixed by #60839
Closed
Assignees
Labels
cut cut, qcut Docs

Comments

@juliangilbey
Copy link

The documentation for pandas.cut says that the output return type depends on the value of the labels parameter, and when this is False:

* False : returns an ndarray of integers.

But if the input to cut is a Series, then the output is as well, either with dtype=int64 if there are no NaNs in the result, or float64 if there are; an example of this behaviour appears in the documentation for the function.

@juliangilbey
Copy link
Author

I forgot to give an example. Here is one giving a Series output with int64; there is an example with float64 in the pandas.cut documentation:

s = pd.Series([0.7, 0.1, -0.4, 0.3, 1.2, -0.8])
bins = [-10, -0.5, 0, 0.5, 10]
pd.cut(s, bins, labels=False)

@Mike-gag
Copy link

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cut cut, qcut Docs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants