-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Code Sample,
from pandas.api.types import is_integer_dtype, is_numeric_dtype, is_string_dtype, is_bool_dtype
import numpy as np
is_numeric_dtype(bool)
# True
is_numeric_dtype(np.bool)
# True
Problem description
is_numeric_dtype is returning true for boolean values
source code below
https://github.com/pandas-dev/pandas/blob/v1.1.5/pandas/core/dtypes/common.py#L1223-L1262
def is_numeric_dtype(arr_or_dtype) -> bool:
"""
Check whether the provided array or dtype is of a numeric dtype.
Parameters
----------
arr_or_dtype : array-like
The array or dtype to check.
Returns
-------
boolean
Whether or not the array or dtype is of a numeric dtype.
Examples
--------
>>> is_numeric_dtype(str)
False
>>> is_numeric_dtype(int)
True
>>> is_numeric_dtype(float)
True
>>> is_numeric_dtype(np.uint64)
True
>>> is_numeric_dtype(np.datetime64)
False
>>> is_numeric_dtype(np.timedelta64)
False
>>> is_numeric_dtype(np.array(['a', 'b']))
False
>>> is_numeric_dtype(pd.Series([1, 2]))
True
>>> is_numeric_dtype(pd.Index([1, 2.]))
True
>>> is_numeric_dtype(np.array([], dtype=np.timedelta64))
False
"""
return _is_dtype_type(
arr_or_dtype, classes_and_not_datetimelike(np.number, np.bool_)
)
Expected Output
is_numeric_dtype(np.bool)
False
pandas : 1.0.4
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : None
setuptools : 46.1.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.0
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.8.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.5.0
matplotlib : 3.1.2
numexpr : None
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.5.0
sqlalchemy : 1.2.14
tables : None
tabulate : 0.8.6
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
numba : None