-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Series.dt.tz_localize not recognizing DST transition with zoneinfo timezone when ambiguous="infer" #48442
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
Comments
In a weird wrinkle, localizing to pytz first and then converting to zoneinfo causes the series to display wrong but have the correct actual values
But just localizing to zoneinfo causes the ambiguous values issue
|
Thanks for the report and diagnosis! Pull requests to correctly set fold in the code path you highlighted would be welcome |
Haven't had to work with Cython before today, but I think I understand the logic of these sections I'm going to try my best to see if I can figure out how to get this working |
The relevant logic for |
Uh oh!
There was an error while loading. Please reload this page.
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
Issue Description
On 1.5.0rc0
Series.dt.tz_localize using a zoneinfo.Zoneinfo timezone does not correctly recognize a daylight savings time transition
Looks like the cause of this is:
DatetimeArray.tz_localize
calls tz_localize_to_utc which instantiates aLocalizer
class asinfo
Localizer
setsself.use_tzlocal = True
because the tz is zoneinfoinfo.use_tzlocal
makes each value get set using _tz_localize_using_tzinfo_api, bypassing any of the ambiguous time checksExpected Behavior
Usage of zoneinfo should match that of pytz or dateutil
Installed Versions
INSTALLED VERSIONS
commit : 224458e
python : 3.10.1.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19044
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 1.5.0rc0
numpy : 1.23.1
pytz : 2022.1
dateutil : 2.8.2
setuptools : 63.4.1
pip : 22.2.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.1
html5lib : None
pymysql : 1.0.2
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.4.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.2
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 7.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : 2022.1
The text was updated successfully, but these errors were encountered: