-
Notifications
You must be signed in to change notification settings - Fork 653
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: Dataframe.astype(...)
Fails With 'bool' object has no attribute 'all'
#7364
Comments
In fact this seems to work ok if in line 1736 in
the ordering of the arguments is swappe, i.e.:
I guess some ordering dependency in how the result is calculated? I can open a PR to change, but not sure if there is some deeper reasoning here. |
I have encountered this issue while working on a separate project and looking into this as the code suggests
flipping the comparison, @zombie-einstein, to me the solution seems correct, but I am new to modin hope one of the maintainters of modin can take a further look into this issue More general context belowhere is an example of why the flipping works:import pandas as pd
s = pd.Series(['a', 'b', 'c'])
int_64 = pd.Int64Dtype()
string = 'a'
print(s == string)
# 0 True
# 1 False
# 2 False
# dtype: bool
print(string == s)
# 0 True
# 1 False
# 2 False
# dtype: bool
print(int_64 == s)
# False
print(s == int_64)
# 0 False
# 1 False
# 2 False
# dtype: bool note on usage and thoughts on it:The documentation of def astype(self, col_dtypes, errors: str = "raise"):
"""
Convert the columns dtypes to given dtypes.
Parameters
----------
col_dtypes : dictionary of {col: dtype,...} or str
Where col is the column name and dtype is a NumPy dtype.
errors : {'raise', 'ignore'}, default: 'raise'
Control raising of exceptions on invalid data for provided dtype.
Returns
-------
BaseDataFrame
Dataframe with updated dtypes.
""" so |
Modin version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest released version of Modin.
I have confirmed this bug exists on the main branch of Modin. (In order to do this you can follow this guide.)
Reproducible Example
Issue Description
I think this is the same error as #7276, but that issue was closed. When using
astype
on a Dataframe it fails at this checkWhen the type argument is a single value (i.e.
astype(pd.Int64Dtype())
) then it seems thatcol_dtypes == self_dtypes
works out as a single bool value (hence noall
attribute).Note that this works Ok if the argument is a dictionary of column namess to dtypes.
This also seems to be the same for Series, i.e.:
Fails with the same error
Expected Behavior
In native Pandas
casts the DataFrame/series to the argument type
Error Logs
No response
Installed Versions
'0.31.0'
The text was updated successfully, but these errors were encountered: