Skip to content
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

BUG/API: constructing nullable integer and floating arrays from boolean data #42137

Closed
mzeitlin11 opened this issue Jun 20, 2021 · 1 comment · Fixed by #50328
Closed

BUG/API: constructing nullable integer and floating arrays from boolean data #42137

mzeitlin11 opened this issue Jun 20, 2021 · 1 comment · Fixed by #50328
Labels
API - Consistency Internal Consistency of API/Behavior Bug Constructors Series/DataFrame/Index/pd.array Constructors NA - MaskedArrays Related to pd.NA and nullable extension arrays

Comments

@mzeitlin11
Copy link
Member

From #41970 (comment), right now constructing nullable integer (and floating) arrays from boolean data has the following behavior:

In [2]: pd.Series([True, False, True, True], dtype='Int64')
Out[2]:
0    1
1    0
2    1
3    1
dtype: Int64

In [3]: pd.Series([True, False, True, pd.NA], dtype='Int64')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
...
TypeError: object cannot be converted to an IntegerDtype

This seems inconsistent, if so, which behavior is correct?

@mzeitlin11 mzeitlin11 added API - Consistency Internal Consistency of API/Behavior Constructors Series/DataFrame/Index/pd.array Constructors NA - MaskedArrays Related to pd.NA and nullable extension arrays labels Jun 20, 2021
@mzeitlin11
Copy link
Member Author

I think having the second case not raise makes sense from a consistency perspective given that you can do something like

>>> pd.Series([True, np.nan, True], dtype=float)
0    1.0
1    NaN
2    1.0

@simonjayhawkins simonjayhawkins added this to the Contributions Welcome milestone Jun 21, 2021
@mroeschke mroeschke added the Bug label Aug 21, 2021
@mroeschke mroeschke removed this from the Contributions Welcome milestone Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior Bug Constructors Series/DataFrame/Index/pd.array Constructors NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
3 participants