Pandas: adding offset to date when DST changes
I'm not sure if this is a pandas bug, or if I am doing something wrong.
Given a date and time like this:
foo_date = pd.Timestamp('2016-10-30 00:00:00',
tz=pytz.timezone('Europe/Helsinki'))
And the offset interval ( 'D'
, '10m'
, whatever), I want to get a start date for the next interval.
I am doing this:
offset = pd.tseries.frequencies.to_offset('D') # 'D' or any other offset, it shouldn't matter
new_date = foo_date + offset
Or like this (same result):
offset = pd.DateOffset(1)
new_date = foo_date + offset
I expect this:
Timestamp('2016-10-31 00:00:00+0200', tz='Europe/Helsinki')
But instead I get this:
Timestamp('2016-10-30 23:00:00+0200', tz='Europe/Helsinki')
The problem is that it 2016-10-30
is 25 hours a day due to the DST change, so when I add offset
it only adds 24 hours and I get the wrong time and time.
I think the time offset should be timezone sensitive, but it looks like it isn't. How can I achieve what I need?
source to share
No one has answered this question yet
Check out similar questions: