Skip to content

BUG: is_integer_dtype does not consider Int16Dtype as an integer dtype #46115

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

Closed
3 tasks done
DriesSchaumont opened this issue Feb 22, 2022 · 3 comments
Closed
3 tasks done
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Usage Question

Comments

@DriesSchaumont
Copy link
Member

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 as pd
>>> pd.api.types.is_integer_dtype(pd.DataFrame([1, 2], dtype=pd.Int16Dtype()))
False

Issue Description

According to the docs (https://pandas.pydata.org/docs/reference/api/pandas.api.types.is_integer_dtype.html):

The nullable Integer dtypes (e.g. pandas.Int64Dtype) are also considered as integer by this function.

Expected Behavior

Should return True

Installed Versions

commit : 06d2301
python : 3.8.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-91-generic
Version : #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.4.1
numpy : 1.22.2
pytz : 2021.3
dateutil : 2.8.2
pip : 20.0.2
setuptools : 44.0.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None

@DriesSchaumont DriesSchaumont added Bug Needs Triage Issue that has not been reviewed by a pandas team member ExtensionArray Extending pandas with custom dtypes or arrays. and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 22, 2022
@asishm
Copy link
Contributor

asishm commented Feb 22, 2022

Changing the DataFrame to a Series works. Don't think this method supports passing DataFrame as input - the docs mention array-like. The primary reason is probably because dataframes can have multiple dtypes.

@mroeschke
Copy link
Member

Correct, is_*_dtypes are only meant to work on scalars and 1D array likes so this behavior is expected

@jreback
Copy link
Contributor

jreback commented Feb 22, 2022

i suppose might be worth adding to the doc string with this as a counter example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Usage Question
Projects
None yet
Development

No branches or pull requests

4 participants