BUG: AttributeError: 'bool' object has no attribute 'to_numpy' in "mask_missing" method of core/missing.py

See original GitHub issue

Pandas 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

image

image

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:open
  • Created a year ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
simonjayhawkinscommented, May 27, 2022

FYI this is not only related to QList.

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.

import pandas as pd

# case 1
df = pd.DataFrame({"d": [pd.NA]})
print(df.replace("", pd.NA))
      d
0  <NA>

Note: the FutureWarning was also given in pandas 1.3.5, but I think that it should probably have been suppressed.

0reactions
simonjayhawkinscommented, Aug 30, 2022
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found