-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: Make nullable booleans numeric #34056
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
Changes from 7 commits
ac20e20
b68b579
1723f05
3a468ec
a4e0c01
01bada6
d001e97
de7c3d4
677b045
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,8 @@ | |
from pandas.core.dtypes.inference import is_list_like | ||
from pandas.core.dtypes.missing import isna, notna | ||
|
||
import pandas as pd | ||
|
||
if TYPE_CHECKING: | ||
from pandas import Series | ||
from pandas.core.arrays import ExtensionArray # noqa: F401 | ||
|
@@ -312,12 +314,11 @@ def maybe_cast_result_dtype(dtype: DtypeObj, how: str) -> DtypeObj: | |
DtypeObj | ||
The desired dtype of the result. | ||
""" | ||
d = { | ||
(np.dtype(np.bool), "add"): np.dtype(np.int64), | ||
(np.dtype(np.bool), "cumsum"): np.dtype(np.int64), | ||
(np.dtype(np.bool), "sum"): np.dtype(np.int64), | ||
} | ||
return d.get((dtype, how), dtype) | ||
if how in ["add", "cumsum", "sum"] and (dtype == np.dtype(np.bool)): | ||
return np.dtype(np.int64) | ||
if how in ["add", "cumsum", "sum"] and isinstance(dtype, pd.BooleanDtype): | ||
dsaxton marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm hitting some circular import issues when I try to import these directly, is it okay to import from within the function itself? |
||
return pd.Int64Dtype() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't use pd There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can either import (best) or return a string "Int64" |
||
return dtype | ||
|
||
|
||
def maybe_cast_to_extension_array(cls: Type["ExtensionArray"], obj, dtype=None): | ||
|
Uh oh!
There was an error while loading. Please reload this page.