-
-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
import pandas as pd
import io
data = '''agency_cd,site_no,datetime,tz_cd,144166_00060,144166_00060_cd,144167_00065,144167_00065_cd
USGS,9333500,2001-05-07 01:00:00,MDT,71.0,A:[91],,
USGS,9333500,2001-05-07 01:15:00,MDT,71.0,A:[91],,
USGS,9333500,2001-05-07 01:30:00,MDT,71.0,A:[91],,
USGS,9333500,2001-05-07 01:45:00,MDT,70.0,A:[91],,
USGS,9333500,2001-05-07 02:00:00,MDT,70.0,A:[91],,
USGS,9333500,2001-05-08 02:15:00,MDT,69.0,A:[91],,
USGS,9333500,2001-05-08 02:30:00,MDT,70.0,A:[91],,
USGS,9333500,2001-05-08 02:45:00,MDT,70.0,A:[91],,
USGS,9333500,2001-05-08 03:00:00,MDT,70.0,A:[91],,'''
df = pd.read_csv(io.StringIO(data), dtype_backend='pyarrow', engine='pyarrow')
def to_denver_time(df_, time_col, tz_col):
return (df_
.assign(**{tz_col: df_[tz_col].replace('MDT', 'MST7MDT')})
.groupby(tz_col)
[time_col]
.transform(lambda s: pd.to_datetime(s)
.dt.tz_localize(s.name, ambiguous=True)
.dt.tz_convert('America/Denver'))
.astype('timestamp[ns, America/Denver][pyarrow]')
)
def tweak_river(df_):
return (df_
.assign(datetime=to_denver_time(df_, 'datetime', 'tz_cd'))
.rename(columns={'144166_00060': 'cfs'})
.loc[:, ['datetime', 'cfs']]
.set_index('datetime')
)
dd = tweak_river(df)
def convert_to_numpy_datetime64(df):
df2 = df.copy()
df2.index = df2.index.astype('datetime64[ns, America/Denver]')
return df2.sort_index()
np_idx = (dd
.pipe(convert_to_numpy_datetime64)
.index)
pa_idx = dd.index
missing_attrs = set(dir(np_idx)) - set(dir(pa_idx))
missing_attrsIssue Description
In the past with numpy backed dates in the index I could do something like
(df
.groupby(df.index.month)
.some_col
.describe()
)
to get summary stats for some_col by calendar month.
With pyarrow date types in the index the .month attribute and many others are missing.
Expected Behavior
Consistency between np and pyarrow time index
Installed Versions
Details
INSTALLED VERSIONS
commit : 7242759
python : 3.11.13
python-bits : 64
OS : Darwin
OS-release : 24.6.0
Version : Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : None
LOCALE : en_US.UTF-8
pandas : 3.0.0rc1
numpy : 2.4.0
dateutil : 2.9.0.post0
pip : 25.3
Cython : 3.2.2
sphinx : None
IPython : 9.8.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.14.3
bottleneck : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.6
lxml.etree : 6.0.2
matplotlib : 3.10.7
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.5
psycopg2 : None
pymysql : None
pyarrow : 22.0.0
pyiceberg : None
pyreadstat : None
pytest : 9.0.2
python-calamine : None
pytz : 2025.2
pyxlsb : None
s3fs : None
scipy : 1.16.3
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
qtpy : None
pyqt5 : None