BUG: Index name lost when using "resample" with pyarrow dtypes · Issue #61222 · pandas-dev/pandas (original) (raw)

Pandas version checks

Reproducible Example

import pandas as pd

Create a df with DatetimeIndex called "timestamp" and native pandas dtype

native_df = pd.DataFrame( {'value': [23.5, 24.1, 22.8, 25.3, 23.9]}, index=pd.date_range(start='2025-01-01 00:00:00', end='2025-01-01 04:00:00', freq='h'), ) native_df.index.name = "timestamp"

Create a similar df with pyarrow dtypes

pyarrow_df = native_df.copy() pyarrow_df.index = pyarrow_df.index.astype('timestamp[ns][pyarrow]') pyarrow_df["value"] = pyarrow_df["value"].astype('float64[pyarrow]')

native_df.resample("2h").mean().reset_index()["timestamp"] # OK pyarrow_df.resample("2h").mean().reset_index()["timestamp"] # KeyError: 'timestamp'

Issue Description

The resample forget the name of the index when using pyarrow dtypes.

By the way, I notice that DatetimeIndex are converted to Index when using pyarrow dtypes. Maybe it is related?

See concrete example in screenshot
Image

Expected Behavior

The resample methods is expected to behave in the same way for pyarrow and native dtypes.

Installed Versions

INSTALLED VERSIONS

python : 3.12.8
python-bits : 64
OS : Linux
OS-release : 5.10.234-225.910.amzn2.x86_64
Version : #1 SMP Fri Feb 14 16:52:40 UTC 2025
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : C.UTF-8
LANG : C.UTF-8
LOCALE : C.UTF-8

pandas : 2.2.3
numpy : 1.26.4
pytz : 2025.1
dateutil : 2.9.0.post0
pip : 25.0.1
Cython : None
sphinx : None
IPython : 8.32.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.3
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2025.3.2
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.5
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 : None
python-calamine : None
pyxlsb : None
s3fs : 2025.3.2
scipy : 1.15.2
sqlalchemy : 2.0.38
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : 0.23.0
tzdata : 2025.2
qtpy : None
pyqt5 : None