-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
ENH: linearly spaced date_range (GH 20808) #20846
Merged
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ddc4479
ENH: linearly spaced date_range (GH 20808)
onnoeberhard e07fd0d
Merge remote-tracking branch 'upstream/master' into daterange
onnoeberhard 2cb62c4
Merge remote-tracking branch 'upstream/master' into daterange
onnoeberhard 73870a7
ENH: linearly spaced date_range (GH 20808)
onnoeberhard 580bca2
ENH: linearly spaced date_range (GH 20808)
onnoeberhard a46307a
ENH: linearly spaced date_range (GH 20808)
onnoeberhard a9b875f
Merge remote-tracking branch 'upstream/master' into daterange
onnoeberhard 2595977
Moved to DTI constructor, removed kwargs functionality
onnoeberhard 5928bd7
Moved to DTI constructor, removed kwargs functionality
onnoeberhard 887e3bb
Merge remote-tracking branch 'upstream/master' into daterange
onnoeberhard 1015e65
Fixed Style Issues
onnoeberhard 4d6cd23
Fixed Style Issues
onnoeberhard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,6 +162,37 @@ def test_date_range_ambiguous_arguments(self): | |
with tm.assert_raises_regex(ValueError, msg): | ||
date_range(start, end, periods=10, freq='s') | ||
|
||
def test_date_range_convenience_periods(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also test this with the |
||
# GH 20808 | ||
rng = date_range('2018-04-24', '2018-04-27', periods=3) | ||
exp = DatetimeIndex(['2018-04-24 00:00:00', '2018-04-25 12:00:00', | ||
'2018-04-27 00:00:00'], freq=None) | ||
|
||
tm.assert_index_equal(rng, exp) | ||
|
||
# Test if kwargs work for the to_datetime function used | ||
rng = date_range('2018-04-24', '2018-04-27', periods=3, box=False) | ||
exp = np.array(['2018-04-24T00:00:00', '2018-04-25T12:00:00', | ||
'2018-04-27T00:00:00'], dtype='datetime64[ns]') | ||
|
||
tm.assert_numpy_array_equal(rng, exp) | ||
|
||
# Test if spacing remains linear if tz changes to dst in range | ||
rng = date_range('2018-04-01 01:00:00', '2018-04-01 04:00:00', | ||
tz='Australia/Sydney', periods=3) | ||
exp = DatetimeIndex(['2018-04-01 01:00:00+11:00', | ||
'2018-04-01 02:00:00+11:00', | ||
'2018-04-01 02:00:00+10:00', | ||
'2018-04-01 03:00:00+10:00', | ||
'2018-04-01 04:00:00+10:00'], freq=None) | ||
|
||
# Test AttributeError is raised if result is not a DatetimeIndex | ||
msg = ("To specify the timezone or a name, the " | ||
"result has to be a DatetimeIndex!") | ||
with tm.assert_raises_regex(AttributeError, msg): | ||
rng = date_range('2018-04-24', '2018-04-27', periods=3.3, | ||
name="abc", box=False) | ||
|
||
def test_date_range_businesshour(self): | ||
idx = DatetimeIndex(['2014-07-04 09:00', '2014-07-04 10:00', | ||
'2014-07-04 11:00', | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this needs to go in the DTI constructor itself. we already do some of this validation, it needs to fit in there. Further you don't need to worry about lots of other things that you are repeating, e.g. tz, which are already handled.