Skip to content

BUG: pd.api.types.is_string_dtype() returns inconsistent results for Categorical series vs dtype #62109

@nsarang

Description

@nsarang

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

series = pd.Categorical(['A', 'B', 'C'])
print(f"is_string_dtype(series): {pd.api.types.is_string_dtype(series)}") # True  
print(f"is_string_dtype(series.dtype): {pd.api.types.is_string_dtype(series.dtype)}") # False

Issue Description

pd.api.types.is_string_dtype() returns inconsistent results when passed a Categorical series directly versus the dtype of that series.

Expected Behavior

IMO, both calls should return False since a Categorical is not a string dtype.

Installed Versions

INSTALLED VERSIONS

commit : c888af6
python : 3.11.0
python-bits : 64
OS : Darwin
OS-release : 24.3.0
Version : Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8122
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.UTF-8

pandas : 2.3.1
numpy : 2.3.1
pytz : 2025.2
dateutil : 2.9.0.post0
pip : 25.0.1
Cython : None
sphinx : None
IPython : 9.4.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.4
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2025.3.0
html5lib : None
hypothesis : 6.138.0
gcsfs : 2025.3.0
jinja2 : 3.1.6
lxml.etree : None
matplotlib : 3.10.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 19.0.1
pyreadstat : None
pytest : 8.3.5
python-calamine : None
pyxlsb : None
s3fs : 2025.3.0
scipy : 1.15.2
sqlalchemy : 2.0.39
tables : None
tabulate : 0.9.0
xarray : 2025.6.1
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds DiscussionRequires discussion from core team before further actionStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions