-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
qcut does not handle infinite values correctly #11113
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
Comments
@chrish42 Are you still facing this issue? |
n = 1
data = list(range(10)) + [np.inf] * n
s = pd.Series(data, index=data)
result = pd.qcut(s, [0.1, 0.9]) result:
|
I am facing the same issue: I was expecting the first and last bin to contain np.inf. This was working in pandas 1.1.5 |
This was referenced Jan 30, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Calling qcut with infinite values in a pandas Series should be a well-defined operation, but it tends to produce wrong results or raise (un-obvious) exceptions. I'm using the following snippet to test:
When called with n=1, it produces the following result:
I don't think that the 0 value and the inf should get assigned to NaN bins. When called with n=2, it now produces:
Again, the binning looks suspicious to me... And when called with n >= 3, I get the following exception:
... which doesn't look very related to the cause at first glance. What is happening here is that the value passed to
_format_label()
and then to the%
operator is a NaN, which is doesn't support.The text was updated successfully, but these errors were encountered: