BUG: AttributeError: 'bool' object has no attribute 'to_numpy' in "mask_missing" method of core/missing.py
See original GitHub issuePandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas
import numpy
from qpython.qcollection import qlist
res = pandas.Series(data=qlist([True, True, False, False], qtype=1, adjust_dtype=False)).replace(False, numpy.NaN)
Issue Description
new_mask = arr == x
this expected to get an array-like object with bool elements, like [False, False, True, ...]
, but when arr
being an special array-like object, like the qlist object in example , the expression returns a single False
, which is a bool object, thus we’ll get the exception shown above
Expected Behavior
returns an array-like object instead of a bool object
Installed Versions
1.4.1
Issue Analytics
- State:
- Created a year ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Python: AttributeError: 'bool' object has no attribute 'all'
You are only checking if both lists are equal, with returns a single boolean. This boolean does not have a .all() method and...
Read more >BUG: DataFrame.replace fails to replace value when column ...
I have checked that this issue has not already been reported. ... na_value=False) AttributeError: 'bool' object has no attribute 'to_numpy'.
Read more >AttributeError: 'bool' object has no attribute 'X' in Python
The Python AttributeError: 'bool' object has no attribute occurs when we try to access an attribute on a boolean value (`True` or `False`)....
Read more >AttributeError: 'bool' object has no attribute '_setup_fields' | Odoo
Hi, I am using nightly version 8.0.20141208, after trying to install my module, I am getting this error Traceback (most recent call last):...
Read more >socrates.peopleanalytics.org/venv/lib64/python3.6/...
This method is most useful when you don't know if your object is a Series or DataFrame, but you do know it has...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @bcmyguest1 for this example.
It does raise a warning
FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
, so I guess this issue will resolve itself in a future pandas.However, this example did work in pandas 1.3.5, so labelling as regression pending further investigation.
Note: the
FutureWarning
was also given in pandas 1.3.5, but I think that it should probably have been suppressed.removing milestone, xref https://github.com/pandas-dev/pandas/issues/47485#issuecomment-1231876960