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

date_range bug? #2906

Closed
xdong opened this issue Feb 20, 2013 · 2 comments · Fixed by #2935
Closed

date_range bug? #2906

xdong opened this issue Feb 20, 2013 · 2 comments · Fixed by #2935
Labels
Bug Datetime Datetime data dtype
Milestone

Comments

@xdong
Copy link

xdong commented Feb 20, 2013

If 'start' is a timezone-aware datetime.datetime or Timestamp, then it will get shifted by several hours.

In [1]: from pandas import *

In [2]: start = Timestamp('20130220 10:00', tz='US/Eastern')

In [3]: start
Out[3]: <Timestamp: 2013-02-20 10:00:00-0500 EST, tz=US/Eastern>

In [4]: dr = date_range(start, periods=2)

In [5]: dr
Out[5]: 
<class 'pandas.tseries.index.DatetimeIndex'>
[2013-02-20 15:00:00, 2013-02-21 15:00:00]
Length: 2, Freq: D, Timezone: US/Eastern

In [6]: dr[0]
Out[6]: <Timestamp: 2013-02-20 15:00:00-0500 EST, tz=US/Eastern>

It seems that start' time component was treated as if it's UTC by date_range.

@Moisan
Copy link
Contributor

Moisan commented Feb 25, 2013

date_range permits to include the timezone with the "tz" arguments like this: dr = date_range(start, periods=2, tz='US/Eastern'). However this fails with an assert that the inferred timezone is not the same as the given timezone. So I suppose the inferred timezone is wrong.
Edit: this seems like a deeper problem unrelated to this issue. I opened a new issue for that.

@stephenwlin
Copy link
Contributor

PR #2935 should do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype
Projects
None yet
4 participants