Skip to content
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: is_bool_dtype 'Series' object has no attribute 'categories' #45615

Closed
3 tasks done
Robbie-Palmer opened this issue Jan 25, 2022 · 4 comments · Fixed by #45616
Closed
3 tasks done

BUG: is_bool_dtype 'Series' object has no attribute 'categories' #45615

Robbie-Palmer opened this issue Jan 25, 2022 · 4 comments · Fixed by #45616
Assignees
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@Robbie-Palmer
Copy link
Contributor

Robbie-Palmer commented Jan 25, 2022

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

from pandas import Series
from pandas.core.dtypes.common import is_bool_dtype

s = Series(['foo', 'bar', 'baz'], dtype='category')
is_bool_dtype(s)

Issue Description

In pandas v1.3.0 the is_bool_dtype function returns False when passed a categorical Series
In pandas v1.4.0 it raises the error :

Traceback (most recent call last):
  File "./pandas/core/dtypes/common.py", line 1322, in is_bool_dtype
    arr_or_dtype = arr_or_dtype.categories
  File "./pandas/core/generic.py", line 5583, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'categories'

Expected Behavior

Expect is_bool_dtype to return False for categorical Series as happened in previous pandas versions

Installed Versions

INSTALLED VERSIONS

commit : bb1f651
python : 3.9.7.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-96-generic
Version : #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 1.4.0
numpy : 1.21.3
pytz : 2021.3
dateutil : 2.8.2
pip : 20.2.4
setuptools : 59.6.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.3.7
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : 5.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None

@Robbie-Palmer Robbie-Palmer added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 25, 2022
@Robbie-Palmer
Copy link
Contributor Author

take

@anchal0997
Copy link

Hi @Robbie-Palmer, I would like to work on this issue. Can you give me more information about this bug?

@Robbie-Palmer
Copy link
Contributor Author

Hi @anchal0997 I have already implemented a fix and put up a PR for it here: #45616

Does the above example not reproduce the error for you?

from pandas import Series
from pandas.core.dtypes.common import is_bool_dtype

s = Series(['foo', 'bar', 'baz'], dtype='category')
is_bool_dtype(s)

@jreback jreback added this to the 1.4.1 milestone Jan 30, 2022
@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 30, 2022
simonjayhawkins added a commit to simonjayhawkins/pandas that referenced this issue Feb 8, 2022
@simonjayhawkins
Copy link
Member

In pandas v1.3.0 the is_bool_dtype function returns False when passed a categorical Series
In pandas v1.4.0 it raises the error :

first bad commit: [c166fe9] CLN/TST: parametrize (#44888)

@simonjayhawkins simonjayhawkins added the Regression Functionality that used to work in a prior pandas version label Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants