-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
pandas/core/dtypes/cast.py
Outdated
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont use pd
import anywhere, rather prefer to import directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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?
pandas/core/dtypes/cast.py
Outdated
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): | ||
return pd.Int64Dtype() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
you can either import (best) or return a string "Int64"
thanks |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Also a decent speedup since this is now going through Cython space: