Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Timestamp.tz and DatetimeIndex.tz are inconsistent when pytz 2024.2 is installed #59833

Open
2 of 3 tasks
boschmic opened this issue Sep 18, 2024 · 2 comments
Open
2 of 3 tasks
Labels
Closing Candidate May be closeable, needs more eyeballs Compat pandas objects compatability with Numpy or Python functions Dependencies Required and optional dependencies Timezones Timezone data dtype

Comments

@boschmic
Copy link

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
t0 = pd.Timestamp("01-01-2000")
print(repr(t0.tz_localize("CET").tz))
print(repr(pd.DatetimeIndex([t0]).tz_localize("CET").tz))

Issue Description

If pytz = "==2024.2" is installed the example prints

<DstTzInfo 'CET' CET+1:00:00 STD>
<DstTzInfo 'CET' LMT+0:18:00 STD>

Downgrading pytzto 2024.1 resolves this issue.

Expected Behavior

The .tz property should produce the same result regardless if the object is a Timestamp or DatetimeIndex. Hence, I expect this example to print

<DstTzInfo 'CET' CET+1:00:00 STD>
<DstTzInfo 'CET' CET+1:00:00 STD>

Installed Versions

INSTALLED VERSIONS ------------------ commit : d9cdd2e python : 3.11.10.final.0 python-bits : 64 OS : Linux OS-release : 6.8.0-40-generic Version : #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 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.2
numpy : 2.1.1
pytz : 2024.2
dateutil : 2.9.0.post0
setuptools : 69.2.0
pip : 24.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None

@boschmic boschmic added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 18, 2024
@lithomas1 lithomas1 added Compat pandas objects compatability with Numpy or Python functions Dependencies Required and optional dependencies Timezones Timezone data dtype and removed Needs Triage Issue that has not been reviewed by a pandas team member Bug labels Sep 18, 2024
@lithomas1
Copy link
Member

Thanks for reporting this.

I think we spotted this in our CI for pandas 2.2.x as well.

@mroeschke
Sorry to ping but do you know what's going wrong?
Looking at pytz's release it looks like all they did was update their tzdata to IANA 2024b.
Maybe we have a conflict between pytz and zoneinfo/tzdata?

@mroeschke
Copy link
Member

Given the documentation in https://pandas.pydata.org/docs/user_guide/timeseries.html#working-with-time-zones (in the Note below), it seems that the ==2024.2 pytz behavior is more correct then the prior.

I don't exactly recall seeing this in the 2.2.x branch.

Additionally, the pandas main branch already removed support for interpreting CET as a pytz timezone and now will infer this as a zoneinfo timezone, so I'm not sure this is likely to be fixed

@mroeschke mroeschke added the Closing Candidate May be closeable, needs more eyeballs label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs Compat pandas objects compatability with Numpy or Python functions Dependencies Required and optional dependencies Timezones Timezone data dtype
Projects
None yet
Development

No branches or pull requests

3 participants