Skip to content

BUG: Discrepancy between .is_numeric() and is_numeric_dtype for bool Index #51152

Closed
@jrbourbeau

Description

@jrbourbeau

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
from pandas.api.types import is_numeric_dtype

idx = pd.Index([True], dtype=bool)

print(f"{idx.is_numeric() = }")
print(f"{is_numeric_dtype(idx) = }")

Issue Description

With the latest nightly wheel of pandas, the following deprecation message is given

FutureWarning: Index.is_numeric is deprecated. Use pandas.api.types.is_numeric_dtype instead

However, when accounting for this deprecation over in dask/dask, we observed that is_numeric() and is_numeric_dtype don't give the same result for and Index with bool data

Expected Behavior

I'd expect these to both give the same answer

Installed Versions

INSTALLED VERSIONS
------------------
commit           : f06c96a93fb2e21c9f801192d9ed5896c5ce3535
python           : 3.10.4.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 22.2.0
Version          : Darwin Kernel Version 22.2.0: Fri Nov 11 02:08:47 PST 2022; root:xnu-8792.61.2~4/RELEASE_X86_64
machine          : x86_64
processor        : i386
byteorder        : little
LC_ALL           : None
LANG             : en_US.UTF-8
LOCALE           : en_US.UTF-8

pandas           : 2.0.0.dev0+1401.gf06c96a93f
numpy            : 1.24.1
pytz             : 2022.1
dateutil         : 2.8.2
setuptools       : 59.8.0
pip              : 22.0.4
Cython           : None
pytest           : 7.1.3
hypothesis       : None
sphinx           : 4.5.0
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : None
html5lib         : 1.1
pymysql          : None
psycopg2         : None
jinja2           : 3.1.2
IPython          : 8.2.0
pandas_datareader: None
bs4              : 4.11.1
bottleneck       : None
brotli           :
fastparquet      : 2022.12.1.dev6
fsspec           : 2023.1.0+5.g012816b
gcsfs            : None
matplotlib       : 3.5.1
numba            : None
numexpr          : 2.8.0
odfpy            : None
openpyxl         : None
pandas_gbq       : None
pyarrow          : 11.0.0.dev316
pyreadstat       : None
pyxlsb           : None
s3fs             : 2022.10.0
scipy            : 1.9.0
snappy           :
sqlalchemy       : 1.4.35
tables           : 3.7.0
tabulate         : None
xarray           : 2022.3.0
xlrd             : None
zstandard        : None
tzdata           : None
qtpy             : None
pyqt5            : None

Metadata

Metadata

Assignees

Labels

BugIndexRelated to the Index class or subclasses

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions