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 breaks DST support of ZoneInfo timezones #54462

Closed
3 tasks done
michelbl opened this issue Aug 8, 2023 · 2 comments
Closed
3 tasks done

BUG: Timestamp breaks DST support of ZoneInfo timezones #54462

michelbl opened this issue Aug 8, 2023 · 2 comments
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@michelbl
Copy link

michelbl commented Aug 8, 2023

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

from datetime import datetime, timedelta
from zoneinfo import ZoneInfo
import pandas as pd

d = datetime(2023, 3, 25, 6, tzinfo=ZoneInfo("Europe/Paris"))
pd.Timestamp(d) + pd.Timedelta(days=1)

returns Timestamp('2023-03-26 07:00:00+0200', tz='Europe/Paris'), which is wrong

pd.Timestamp(d) + timedelta(days=1) also gives the wrong result.

Issue Description

One day after the initial timestamp, the hour count should not have changed. Even if that day has only 23 hours because of DST.

Apparently, Timestamp does not alter the timezone because pd.Timestamp(d).tz == d.tzinfo, yet it changes its behavior.

Expected Behavior

Using the same example, d + pd.Timedelta(days=1) or d + timedelta(days=1) returns the correct result : datetime.datetime(2023, 3, 26, 6, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Paris')))

Installed Versions

INSTALLED VERSIONS
------------------
commit              : 5f672dc70479de509f7f10f9f39f27539c2defa3
python              : 3.11.4.final.0
python-bits         : 64
OS                  : Linux
OS-release          : 5.19.0-50-generic
Version             : #50-Ubuntu SMP PREEMPT_DYNAMIC Mon Jul 10 18:24:29 UTC 2023
machine             : x86_64
processor           : x86_64
byteorder           : little
LC_ALL              : None
LANG                : en_US.UTF-8
LOCALE              : en_US.UTF-8

pandas              : 2.1.0.dev0+1421.g5f672dc704
numpy               : 2.0.0.dev0+766.g8627dc962
pytz                : 2023.3
dateutil            : 2.8.2
setuptools          : 67.8.0
pip                 : 23.1.2
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
bs4                 : None
bottleneck          : None
brotli              : 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
pyxlsb              : None
s3fs                : None
scipy               : None
snappy              : None
sqlalchemy          : None
tables              : None
tabulate            : None
xarray              : None
xlrd                : None
zstandard           : None
tzdata              : 2023.3
qtpy                : None
pyqt5               : None
@michelbl michelbl added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 8, 2023
@michelbl michelbl changed the title BUG: Timestamp breaks DST support on ZoneInfo timezones BUG: Timestamp breaks DST support of ZoneInfo timezones Aug 8, 2023
@MarcoGorelli
Copy link
Member

thanks for your report - this will be closed by #51874, so closing for now

@michelbl
Copy link
Author

michelbl commented Aug 8, 2023

Marvelous, thanks! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants