-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: date_range linspace behavior respects tz #20988
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
Conversation
Beat me by a few minutes! Can you modify the test that was originally written for this behavior: pandas/pandas/tests/indexes/datetimes/test_date_range.py Lines 165 to 180 in b3f07b2
The timezone transition portion isn't being tested, as there's no In [2]: pd.date_range('2018-04-01 01:00:00', '2018-04-01 04:00:00', tz='Australia/Sydney', periods=3)
Out[2]:
DatetimeIndex(['2018-04-01 01:00:00+11:00', '2018-04-01 02:00:00+10:00',
'2018-04-01 04:00:00+10:00'],
dtype='datetime64[ns, Australia/Sydney]', freq=None) (Note that the above is evenly spaced due to the DST transition) |
Timestamp('20180103', tz='US/Eastern')]]) | ||
def test_date_range_linspacing_tz(self, start, end): | ||
# GH 20983 | ||
result = date_range(start, end, periods=3, tz='US/Eastern') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be beneficial to test when start
/end
are tz aware but not specifying the tz
param for date_range
, to ensure that tz
inference from start
/end
is okay.
Codecov Report
@@ Coverage Diff @@
## master #20988 +/- ##
==========================================
+ Coverage 91.82% 91.82% +<.01%
==========================================
Files 153 153
Lines 49490 49489 -1
==========================================
+ Hits 45443 45444 +1
+ Misses 4047 4045 -2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. small comment by @jschendel
pandas/core/indexes/datetimes.py
Outdated
@@ -587,10 +587,13 @@ def _generate(cls, start, end, periods, name, freq, | |||
if end is not None: | |||
end = end.tz_localize(tz).asm8 | |||
else: | |||
# Create a linearly spaced date_range. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specifiy this is in local time
Sorry for jumping the gun @jschendel! Thanks for the review and nice catch with the missing assert. Addressed your comment as well @jreback |
thanks @mroeschke and @jschendel |
git diff upstream/master -u -- "*.py" | flake8 --diff