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

BUG: date_range(str, tz=str) and date_range(Timestamp) handle tz discontinuity differently #7835

Closed
ischwabacher opened this issue Jul 24, 2014 · 0 comments · Fixed by #7909
Labels
Bug Timezones Timezone data dtype
Milestone

Comments

@ischwabacher
Copy link
Contributor

xref #7825
xref (addtl test cases) #7901

I believe Out[2] is correct and Out[3] is a bug, and that others will agree with me.
I believe Out[4] is a bug, Out[7] is correct and Out[10] is a bug, but that I will have to do some work to convince others to agree with me.

In [1]: import pandas as pd

In [2]: list(pd.date_range('2013-11-1', tz='America/Chicago', periods=7, freq='D'))
Out[2]: 
[Timestamp('2013-11-01 00:00:00-0500', tz='America/Chicago', offset='D'),
 Timestamp('2013-11-02 00:00:00-0500', tz='America/Chicago', offset='D'),
 Timestamp('2013-11-03 00:00:00-0500', tz='America/Chicago', offset='D'),
 Timestamp('2013-11-04 00:00:00-0600', tz='America/Chicago', offset='D'),
 Timestamp('2013-11-05 00:00:00-0600', tz='America/Chicago', offset='D'),
 Timestamp('2013-11-06 00:00:00-0600', tz='America/Chicago', offset='D'),
 Timestamp('2013-11-07 00:00:00-0600', tz='America/Chicago', offset='D')]

In [3]: list(pd.date_range(pd.Timestamp('2013-11-1', tz='America/Chicago'), periods=7, freq='D'))
Out[3]: 
[Timestamp('2013-11-01 00:00:00-0500', tz='America/Chicago', offset='D'),
 Timestamp('2013-11-02 00:00:00-0500', tz='America/Chicago', offset='D'),
 Timestamp('2013-11-03 00:00:00-0500', tz='America/Chicago', offset='D'),
 Timestamp('2013-11-03 23:00:00-0600', tz='America/Chicago', offset='D'),
 Timestamp('2013-11-04 23:00:00-0600', tz='America/Chicago', offset='D'),
 Timestamp('2013-11-05 23:00:00-0600', tz='America/Chicago', offset='D'),
 Timestamp('2013-11-06 23:00:00-0600', tz='America/Chicago', offset='D')]

In [4]: list(pd.date_range('2013-11-1', tz='America/Chicago', periods=7, freq='24H'))
Out[4]: 
[Timestamp('2013-11-01 00:00:00-0500', tz='America/Chicago', offset='24H'),
 Timestamp('2013-11-02 00:00:00-0500', tz='America/Chicago', offset='24H'),
 Timestamp('2013-11-03 00:00:00-0500', tz='America/Chicago', offset='24H'),
 Timestamp('2013-11-04 00:00:00-0600', tz='America/Chicago', offset='24H'),
 Timestamp('2013-11-05 00:00:00-0600', tz='America/Chicago', offset='24H'),
 Timestamp('2013-11-06 00:00:00-0600', tz='America/Chicago', offset='24H'),
 Timestamp('2013-11-07 00:00:00-0600', tz='America/Chicago', offset='24H')]

In [5]: out = [pd.Timestamp('2013-11-1', tz='America/Chicago')]

In [6]: for i in range(6):
   ...:     out.append(out[-1] + pd.offsets.Hour(24))
   ...:      

In [7]: out
Out[7]: 
[Timestamp('2013-11-01 00:00:00-0500', tz='America/Chicago'),
 Timestamp('2013-11-02 00:00:00-0500', tz='America/Chicago'),
 Timestamp('2013-11-03 00:00:00-0500', tz='America/Chicago'),
 Timestamp('2013-11-03 23:00:00-0600', tz='America/Chicago'),
 Timestamp('2013-11-04 23:00:00-0600', tz='America/Chicago'),
 Timestamp('2013-11-05 23:00:00-0600', tz='America/Chicago'),
 Timestamp('2013-11-06 23:00:00-0600', tz='America/Chicago')]

In [8]: out = [pd.Timestamp('2013-11-1', tz='America/Chicago')]

In [9]: for i in range(6):
   ...:     out.append(out[-1] + pd.offsets.Day(1))
   ...:      

In [10]: out
Out[10]: 
[Timestamp('2013-11-01 00:00:00-0500', tz='America/Chicago'),
 Timestamp('2013-11-02 00:00:00-0500', tz='America/Chicago'),
 Timestamp('2013-11-03 00:00:00-0500', tz='America/Chicago'),
 Timestamp('2013-11-03 23:00:00-0600', tz='America/Chicago'),
 Timestamp('2013-11-04 23:00:00-0600', tz='America/Chicago'),
 Timestamp('2013-11-05 23:00:00-0600', tz='America/Chicago'),
 Timestamp('2013-11-06 23:00:00-0600', tz='America/Chicago')]
@jreback jreback changed the title BUG: date_range(str, tz=str) and date_range(Timestamp) handle tz discontinuity differently BUG: date_range(str, tz=str) and date_range(Timestamp) handle tz discontinuity differently Jul 24, 2014
@jreback jreback added this to the 0.15.0 milestone Jul 24, 2014
jreback added a commit that referenced this issue Aug 5, 2014
Remove from start/end dates if tz is not None (#7901, #7835)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants