Skip to content

BUG: inconsistent behavior of pandas.api.types.pandas_dtype #58643

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
2 of 3 tasks
aaravind100 opened this issue May 8, 2024 · 2 comments
Open
2 of 3 tasks

BUG: inconsistent behavior of pandas.api.types.pandas_dtype #58643

aaravind100 opened this issue May 8, 2024 · 2 comments
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@aaravind100
Copy link

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

print(pd.api.types.pandas_dtype(pd.ArrowDtype(pyarrow.string())))  # <- correct
# output: string[pyarrow]
print(pd.api.types.pandas_dtype("string"), pd.api.types.pandas_dtype("string[pyarrow]"))  # <- incorrect
# output: string string

Issue Description

pd.api.types.pandas_dtype behavior is inconsistent when called for the str string[pyarrow] which returns type string instead of type string[pyarrow], compared to other types which returns type <type>[pyarrow].

Expected Behavior

pd.api.types.pandas_dtype to return type string[pyarrow] for input str string[pyarrow]

Installed Versions

INSTALLED VERSIONS

commit : d9cdd2e
python : 3.11.9.final.0
python-bits : 64
OS : Linux
OS-release : 6.8.0-31-generic
Version : #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.2.2
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 69.5.1
pip : 24.0
Cython : 3.0.10
pytest : 8.1.1
hypothesis : 6.100.1
sphinx : 7.3.4
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.3
IPython : 8.23.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.3.1
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 15.0.2
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.13.0
sqlalchemy : 2.0.29
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None

@aaravind100 aaravind100 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 8, 2024
@rajat315315
Copy link

It seems this code stops it from inferring correct dtype.

@aaravind100
Copy link
Author

I was wondering if this is for backwards compatibility as per this comment.

unionai-oss/pandera#1628 (comment)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants