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

NonExistentTimeError after Resample #19375

Closed
jackalack opened this issue Jan 24, 2018 · 2 comments · Fixed by #22809
Closed

NonExistentTimeError after Resample #19375

jackalack opened this issue Jan 24, 2018 · 2 comments · Fixed by #22809
Labels
Bug Resample resample method Timeseries Timezones Timezone data dtype
Milestone

Comments

@jackalack
Copy link

Code Sample

import pandas as pd
import numpy as np
import pytz 
index=pd.date_range('2017-03-12', '2017-03-12 1:45:00', freq='15T')
my_series = pd.Series(np.zeros(len(index)), index=index)
my_series = my_series.tz_localize('US/Pacific')
my_series.resample('900S').mean()

Some Version Information:

Python: 3.6.2
pandas: 0.22.0
pytz: 2017.3
numpy: 1.13.0

Problem description

The above code returns the error message NonExistentTimeError: 2017-03-12 02:00:00; however, the input series only contains timestamps up to 2017-03-12 01:45:00. Does anyone understand why this error is occurring? If so, how can I address the problem?

@gfyoung
Copy link
Member

gfyoung commented Jan 24, 2018

@jackalack : AFAICT, this error is occurring because it's a bug 😄 PR to patch is welcome!

@markjszy
Copy link

markjszy commented Jan 24, 2018

Had a quick look into this and can reproduce consistently. Exception is thrown by pandas/_libs/tslibs/conversion.pyx#tz_localize_to_utc

I isolated the values from the example above, and found some others that also result in an exception like this. Time zone and last_dst values don't seem to make a difference.

from pandas._libs.lib import Timestamp

fresult = 1489276800000000000
lresult = 1489284000000000000
last_tzinfo = 'US/Pacific'
last_dst = False

# this is fine
Timestamp(fresult).tz_localize(last_tzinfo, ambiguous=last_dst)

# this is not
Timestamp(lresult).tz_localize(last_tzinfo, ambiguous=last_dst)

# other problematic examples
Timestamp(1489285000000000000).tz_localize(last_tzinfo, ambiguous=last_dst)
Timestamp(1489286000000000000).tz_localize(last_tzinfo, ambiguous=last_dst)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Resample resample method Timeseries Timezones Timezone data dtype
Projects
None yet
6 participants