-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
Unexpected behavior in cut() with nullable Int64 dtype #30787
Labels
cut
cut, qcut
ExtensionArray
Extending pandas with custom dtypes or arrays.
good first issue
Missing-data
np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
NA - MaskedArrays
Related to pd.NA and nullable extension arrays
Needs Tests
Unit test(s) needed to prevent regressions
Comments
Looks like there's an additional complication on In [1]: import numpy as np; import pandas as pd; pd.__version__
Out[1]: '0.26.0.dev0+1674.gbe1556c46'
In [2]: series = pd.Series([0, 1, 2, 3, 4, np.nan, 6, 7], dtype='Int64')
In [3]: breaks = [0, 2, 4, 6, 8]
In [4]: pd.cut(series, breaks)
---------------------------------------------------------------------------
TypeError: boolean value of NA is ambiguous |
take |
What should the expected behavior be? |
This works on main, may need tests
|
17 tasks
take |
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cut
cut, qcut
ExtensionArray
Extending pandas with custom dtypes or arrays.
good first issue
Missing-data
np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
NA - MaskedArrays
Related to pd.NA and nullable extension arrays
Needs Tests
Unit test(s) needed to prevent regressions
Code Sample
Problem Description
When using the
pd.Int64
nullable integer data type,pd.cut()
unexpectedly bins the first non-np.nan
value after annp.nan
into the lowest interval. In the above example, the number6
is binned into(0.0, 2.0]
.Expected Output
Note that using an
IntervalIndex
produces the expected output.Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: