-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REF: simplify DTI._parse_string_to_bounds #31519
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
Merged
jreback
merged 7 commits into
pandas-dev:master
from
jbrockmendel:parsed_string_to_bounds
Feb 5, 2020
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9ae8c96
BUG: Period[us] start_time off by 1 nanosecond
jbrockmendel 430fdcf
catch overflows
jbrockmendel 63cd89a
Merge branch 'master' of https://github.com/pandas-dev/pandas into bu…
jbrockmendel 9490545
GH ref, whatsnew
jbrockmendel 85e47a0
REF: make DTI._parsed_string_to_bounds work like PI implementation
jbrockmendel 4c1ae1e
Merge branch 'master' of https://github.com/pandas-dev/pandas into pa…
jbrockmendel 49f9709
Merge branch 'master' of https://github.com/pandas-dev/pandas into pa…
jbrockmendel 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
from pandas._libs.tslibs.frequencies import INVALID_FREQ_ERR_MSG, _period_code_map | ||
from pandas.errors import OutOfBoundsDatetime | ||
|
||
from pandas import Period, offsets | ||
from pandas import Period, Timestamp, offsets | ||
|
||
|
||
class TestFreqConversion: | ||
|
@@ -656,6 +656,23 @@ def test_conv_secondly(self): | |
|
||
assert ival_S.asfreq("S") == ival_S | ||
|
||
def test_conv_microsecond(self): | ||
# GH#31475 Avoid floating point errors dropping the start_time to | ||
# before the beginning of the Period | ||
per = Period("2020-01-30 15:57:27.576166", freq="U") | ||
assert per.ordinal == 1580399847576166 | ||
|
||
start = per.start_time | ||
expected = Timestamp("2020-01-30 15:57:27.576166") | ||
assert start == expected | ||
assert start.value == per.ordinal * 1000 | ||
|
||
per2 = Period("2300-01-01", "us") | ||
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. Can you split this off into a separate 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. sure |
||
with pytest.raises(OutOfBoundsDatetime, match="2300-01-01"): | ||
per2.start_time | ||
with pytest.raises(OutOfBoundsDatetime, match="2300-01-01"): | ||
per2.end_time | ||
|
||
def test_asfreq_mult(self): | ||
# normal freq to mult freq | ||
p = Period(freq="A", year=2007) | ||
|
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.
unrelated but have you ever thought about renaming this function to something like "int64ns_to_datetimestruct"? I always find myself thinking about what a "pandas_datetime" is
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.
i generally agree. i think it got this name because the numpy version is numpy_datetime_to_datetimestruct or something along those lines.