-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
Description
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.api.types import (
is_object_dtype,
is_datetime64_dtype,
is_datetime64tz_dtype,
is_timedelta64_dtype,
is_period_dtype,
is_interval_dtype,
is_categorical_dtype,
is_string_dtype,
is_integer_dtype,
is_signed_integer_dtype,
is_unsigned_integer_dtype,
is_int64_dtype,
is_datetime64_any_dtype,
is_datetime64_ns_dtype,
is_timedelta64_ns_dtype,
is_numeric_dtype,
is_float_dtype,
is_bool_dtype,
is_extension_array_dtype,
is_complex_dtype,
)
from pandas.core.dtypes.dtypes import ExtensionDtype
trylist = [
is_object_dtype,
is_datetime64_dtype,
is_datetime64tz_dtype,
is_timedelta64_dtype,
is_period_dtype,
is_interval_dtype,
is_categorical_dtype,
is_string_dtype,
is_integer_dtype,
is_signed_integer_dtype,
is_unsigned_integer_dtype,
is_int64_dtype,
is_datetime64_any_dtype,
is_datetime64_ns_dtype,
is_timedelta64_ns_dtype,
is_numeric_dtype,
is_float_dtype,
is_bool_dtype,
is_extension_array_dtype,
is_complex_dtype,
]
for isfunc in trylist:
name = isfunc.__name__
try:
isfunc(ExtensionDtype)
print(" OK ", name)
except Exception:
print("FAILS ", name)Issue Description
There is an inconsistency in whether the is_*_dtype() methods accept ExtensionDtype as a parameter.
Results of above code:
FAILS is_object_dtype
FAILS is_datetime64_dtype
OK is_datetime64tz_dtype
FAILS is_timedelta64_dtype
OK is_period_dtype
OK is_interval_dtype
OK is_categorical_dtype
OK is_string_dtype
FAILS is_integer_dtype
FAILS is_signed_integer_dtype
FAILS is_unsigned_integer_dtype
FAILS is_int64_dtype
FAILS is_datetime64_any_dtype
OK is_datetime64_ns_dtype
OK is_timedelta64_ns_dtype
FAILS is_numeric_dtype
FAILS is_float_dtype
OK is_bool_dtype
OK is_extension_array_dtype
FAILS is_complex_dtype
Discovered as a result of trying to fix a reported pandas-stubs issue pandas-dev/pandas-stubs#514
Expected Behavior
All of those methods should accept ExtensionDtype (and any subclasses of that type) as a parameter
Installed Versions
INSTALLED VERSIONS
commit : 2e218d1
python : 3.9.13.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 13, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 1.5.3
numpy : 1.24.1
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 66.1.0
pip : 22.3.1
Cython : 0.29.33
pytest : 7.2.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.0.7
lxml.etree : 4.8.0
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.6.3
numba : None
numexpr : 2.8.4
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 10.0.1
pyreadstat : 1.2.0
pyxlsb : 1.0.10
s3fs : None
scipy : 1.10.0
snappy : None
sqlalchemy : 1.4.45
tables : 3.8.0
tabulate : 0.9.0
xarray : 2023.1.0
xlrd : 2.0.1
xlwt : None
zstandard : None
tzdata : None