Skip to content

Hitting AmbiguousTimeError when exiting DST using .loc #20724

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

Closed
jackalack opened this issue Apr 17, 2018 · 2 comments · Fixed by #22201
Closed

Hitting AmbiguousTimeError when exiting DST using .loc #20724

jackalack opened this issue Apr 17, 2018 · 2 comments · Fixed by #22201
Labels
good first issue Testing pandas testing functions or related to the test suite Timezones Timezone data dtype
Milestone

Comments

@jackalack
Copy link

jackalack commented Apr 17, 2018

Code Sample, a copy-pastable example if possible

import pandas as pd
import arrow
import datetime
from dateutil import tz

test_time = arrow.get(datetime.datetime(2015,11,1), "US/Pacific").datetime
timestamps = [test_time + datetime.timedelta(seconds=i * 900) for i in range(16)]
my_series = pd.Series([0], index=[timestamps[0].replace(tzinfo=None)])
my_series = my_series.tz_localize(tz.gettz("US/Pacific"), ambiguous='infer')

for ts in timestamps:
    my_series.loc[ts] = 1

Problem description

I have a program that is running as a service and slowly adds timestamps to a pandas series. When running simulations, it always breaks when exiting DST.

INSTALLED VERSIONS

commit: None
python: 2.7.10.final.0
python-bits: 64
OS: Darwin
OS-release: 17.4.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None

pandas: 0.22.0
pytest: None
pip: 9.0.1
setuptools: 38.2.3
Cython: 0.24
numpy: 1.13.3
scipy: 0.18.1
pyarrow: None
xarray: None
IPython: 5.5.0
sphinx: None
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.1.0
openpyxl: None
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.5.1
html5lib: 1.0b10
sqlalchemy: 1.2.4
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@WillAyd
Copy link
Member

WillAyd commented Apr 18, 2018

I could not run the example provided, as name 'tz' is not defined - can you post a minimally reproducible example to describe the issue and expected behavior?

@jackalack
Copy link
Author

jackalack commented Apr 18, 2018

@WillAyd apologies, I missed that import. Just updated it above

@jackalack jackalack reopened this Apr 18, 2018
@jbrockmendel jbrockmendel added the Timezones Timezone data dtype label Jul 25, 2018
@mroeschke mroeschke added Testing pandas testing functions or related to the test suite good first issue labels Jul 31, 2018
@jreback jreback added this to the 0.24.0 milestone Aug 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Testing pandas testing functions or related to the test suite Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants