-
Notifications
You must be signed in to change notification settings - Fork 912
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] Negating a boolean Series changes its dtype to int8
#12397
Comments
Should we match Pandas behaviour here? |
Pandas doesn't promote types in uops, so unsigned types stay unsigned, whereas cudf does: import pandas as pd
import numpy as np
for dtype in ["bool", "uint8", "int8", "uint64", "int64"]:
if dtype == "bool":
dtype_max = True
dtype_min = False
else:
dtype = np.dtype(dtype)
dtype_max = np.iinfo(dtype).max
dtype_min = np.iinfo(dtype).min
s = pd.Series([1], dtype=dtype)
print(s.dtype, (-s).dtype)
s = pd.Series([dtype_max], dtype=dtype)
print(s.dtype, (-s).dtype)
s = pd.Series([dtype_max], dtype=dtype)
print(s.dtype, (-s).dtype)
# bool bool
# bool bool
# bool bool
# uint8 uint8
# uint8 uint8
# uint8 uint8
# int8 int8
# int8 int8
# int8 int8
# uint64 uint64
# uint64 uint64
# uint64 uint64
# int64 int64
# int64 int64
# int64 int64
As we can see, cudf promotes to the next signed type that is wide enough to hold the range of values that the unsigned type has (including promoting Finally, numpy raises
I think we should match pandas here. |
Note in general that type promotion involving booleans probably needs special case handling because I am not sure we do the right thing for binops now either. |
It looks like we resolved the original issue at some point here:
|
In Pandas, negating a
bool
Series behaves as follows:Whereas in cuDF:
The text was updated successfully, but these errors were encountered: