-
-
Notifications
You must be signed in to change notification settings - Fork 19.7k
Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this issue exists on the latest version of pandas.
-
I have confirmed this issue exists on the main branch of pandas.
Reproducible Example
Hello,
Function allowing to get attributes on time index like .month, .year are 10 times slower when the time index is built from a ZoneInfo instead of a pytz.timezone.
With pandas 2.2.3, 3.0.1 or from main, with the use of ZoneInfo:
$ python -m timeit -n 200 -s 'import pandas as pd; from zoneinfo import ZoneInfo' 'pd.date_range("2024-01-01", "2024-12-31 23:59:59", freq="1min", tz=ZoneInfo("Europe/Paris")).month'
200 loops, best of 5: 119 msec per loopWith pandas 2.2.3, 3.0.1 or from main with pytz and dztada installed, with the use of pytz timezone:
$ python -m timeit -n 1000 -s 'import pandas as pd;from pytz import timezone' 'pd.date_range("2024-01-01", "2024-12-31 23:59:59", freq="1min", tz=timezone("Europe/Paris")).month'
1000 loops, best of 5: 11.3 msec per loopSame behavior with year, day, hour and minute but I didn't check others.
Installed Versions
Details
INSTALLED VERSIONS
commit : 0691c5c
python : 3.11.14
python-bits : 64
OS : Linux
OS-release : 6.17.0-14-generic
Version : #14~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Jan 15 15:52:10 UTC 2
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.3
numpy : 2.4.2
pytz : 2025.2
dateutil : 2.9.0.post0
pip : 24.0
Cython : None
sphinx : None
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : None
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 22.0.0
pyreadstat : None
pytest : 8.3.5
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : 2.0.25
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.3
qtpy : None
pyqt5 : None
Prior Performance
No response