-
-
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
In [1]: import pandas as pd
In [2]: pd.__version__
Out[2]: '3.0.0rc0'
In [3]: s = pd.Series(["a", "b", "c"])
In [4]: s.dtype
Out[4]: <StringDtype(na_value=nan)>
In [5]: s = pd.Series(["a", "b", "c"], index=['1', '2', '3'])
In [6]: s.index
Out[6]: Index(['1', '2', '3'], dtype='str')
In [7]: s.index.dtype
Out[7]: <StringDtype(na_value=nan)>
In [9]: res = s.str.cat(["A", "B", "C"], sep=",", na_rep="-")
In [10]: res
Out[10]:
1 a,A
2 b,B
3 c,C
dtype: str
In [11]: res.dtype
Out[11]: <StringDtype(na_value=nan)>
In [12]: res.index
Out[12]: Index(['1', '2', '3'], dtype='str')
In [13]: res.index.dtype
Out[13]: <StringDtype(na_value=nan)>
In [14]: res = s.str.cat(pd.Series(["A", "B", "C"]), sep=",", na_rep="-")
In [15]: res
Out[15]:
1 a,-
2 b,-
3 c,-
dtype: str
In [16]: res.index
Out[16]: Index(['1', '2', '3'], dtype='object')
In [24]: res.index.dtype
Out[24]: dtype('O')Issue Description
I was expecting res.index to have same dtype instead of str vs object. Is this expected?
Expected Behavior
In [16]: res.index
Out[16]: Index(['1', '2', '3'], dtype='str')
Installed Versions
Details
In [21]: pd.show_versions()
INSTALLED VERSIONS
commit : 1a3230d
python : 3.13.11
python-bits : 64
OS : Linux
OS-release : 6.14.0-36-generic
Version : #36~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Oct 15 15:45:17 UTC 2
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 3.0.0rc0
numpy : 2.2.6
dateutil : 2.9.0.post0
pip : 25.3
Cython : 3.1.7
sphinx : 8.2.3
IPython : 9.8.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.14.3
bottleneck : None
fastparquet : None
fsspec : 2025.12.0
html5lib : None
hypothesis : 6.148.7
gcsfs : None
jinja2 : 3.1.6
lxml.etree : None
matplotlib : None
numba : 0.61.2
numexpr : None
odfpy : None
openpyxl : 3.1.5
psycopg2 : None
pymysql : None
pyarrow : 21.0.0
pyiceberg : None
pyreadstat : None
pytest : 9.0.2
python-calamine : None
pytz : 2025.2
pyxlsb : None
s3fs : 2025.12.0
scipy : 1.16.3
sqlalchemy : 2.0.45
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
xlsxwriter : None
zstandard : 0.25.0
qtpy : None
pyqt5 : None