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

Comments

Projects
None yet
2 participants
Contributor

ischwabacher commented Jul 24, 2014

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 changed the title from BUG: `date_range(str, tz=str)` and `date_range(Timestamp)` handle tz discontinuity differently to BUG: date_range(str, tz=str) and date_range(Timestamp) handle tz discontinuity differently Jul 24, 2014

jreback added this to the 0.15.0 milestone Jul 24, 2014

jreback closed this in #7909 Aug 5, 2014

@jreback jreback added a commit that referenced this issue Aug 5, 2014

@jreback jreback Merge pull request #7909 from rockg/master
Remove from start/end dates if tz is not None (#7901, #7835)
7568018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment