-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Partial support only for extension DTypes in pandas.core.dtypes.common
#45417
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
Comments
pandas.core.dtypes.common
pandas.core.dtypes.common
Best guess is that in pdc.pandas_dtype we return the class instead of giving an instance. I think changing that would solve this, not sure if the current behavior is intentional. I think changing this would also fix #31356 |
@jbrockmendel Yes, passing |
Moreover, |
And parameterize while we're at it.
the is_ only take instances and not classes themselves so this is intentional and works correctly for non EA types linked PR to address a better error message |
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
Issue Description
The above code returns a
property
and notbool
.The bug here is actually because of
pandas.core.dtypes.common.get_dtype
that doesn't deal with extension DTypes (I guess it should return the extension DType, but I'm unsure). On the other hand, if theget_dtype
method should not work with extension DTypes (for some reason), then it should check if this in an extension DType prior to callingget_dtype
.Anyway,
is_bool_dtype
should return a boolean and it doesn't necessarily do so (and I'm sure that it's a problem with many other functions in this module).This is also the issue with not inferring strings that represent extension DTypes. Calling
yields
Thanks
p.s. Regarding checking the bug's existence, I encountered it in my python v.3.6.9 code (so it can't be updated to the latest), but I checked the code in the repo, and I'm quite sure that it should reproduce.
Expected Behavior
get_dtype(ExtensionDtype)
should return that DType.is_bool_dtype
and similar should always return boolean values.is_bool_dtype('boolean')
should not raise an exception.is_bool_dtype(pd.BooleanDtype)
should returnTrue
(likepdc.is_bool_dtype(pd.Series([], dtype='boolean'))
does)Installed Versions
INSTALLED VERSIONS
commit : 2a7d332
python : 3.6.9.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-77-generic
Version : #86~18.04.1-Ubuntu SMP Fri Jun 18 01:23:22 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.1.2
numpy : 1.19.5
pytz : 2018.3
dateutil : 2.8.1
pip : 21.1.3
setuptools : 45.2.0
Cython : 0.29.21
pytest : 5.3.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.0
html5lib : 0.999999999
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.16.1
pandas_datareader: None
bs4 : 4.9.3
bottleneck : None
fsspec : 0.8.7
fastparquet : 0.4.1
gcsfs : None
matplotlib : 3.3.4
numexpr : 2.7.2
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : 4.0.1
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.4.17
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.16.0
xlrd : 1.2.0
xlwt : None
numba : 0.48.0
The text was updated successfully, but these errors were encountered: