BUG: dt.tz_convert() on categorical[datetime] resets index #43080
Labels
Bug
Categorical
Categorical Data Type
Reshaping
Concat, Merge/Join, Stack/Unstack, Explode
Timezones
Timezone data dtype
Milestone
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample
Problem description
When working on categorical columns, I would expect all methods, that can be called without error or warning, to yield the same results as when applied to the pure (category-expanded) columns. Some methods from the
.dt
-namespace (at leasttz_localize()
andtz_convert()
) seem to return non-consistent results.In particular, they reset the index of the input column (a Series in fact).
Expected Output
I expect the method
.dt.tz_localize()
to not reset the index when applied to a Series of datetime categoricals.Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 5f648bf
python : 3.9.6.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.14393
machine : AMD64
processor : Intel64 Family 6 Model 85 Stepping 0, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : de_DE.cp1252
pandas : 1.3.2
numpy : 1.21.2
pytz : 2021.1
dateutil : 2.8.2
pip : 21.2.4
setuptools : 57.4.0
Cython : None
pytest : 6.2.4
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: