-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: pd.DateOffset handle milliseconds #50020
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
Changes from all commits
48d9dfa
65cd5da
f989674
b3a5ef1
37427dd
705d2d6
c1be7c6
1788491
ae0b529
64c9ee3
65015c8
ef7f118
b2b7473
c2cf081
3981b04
d80e780
27109a7
76fafe2
2ad8c60
2f913a8
8eb83d0
309e296
0d85a74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -739,6 +739,33 @@ def test_eq(self): | |
|
||
assert DateOffset(milliseconds=3) != DateOffset(milliseconds=7) | ||
|
||
@pytest.mark.parametrize( | ||
"offset_kwargs, expected_arg", | ||
[ | ||
({"microseconds": 1, "milliseconds": 1}, "2022-01-01 00:00:00.001001"), | ||
({"seconds": 1, "milliseconds": 1}, "2022-01-01 00:00:01.001"), | ||
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. should there be a test to check when both 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. (CI failures are unrelated BTW, if you fetch and merge upstream/main they should be fixed) |
||
({"minutes": 1, "milliseconds": 1}, "2022-01-01 00:01:00.001"), | ||
({"hours": 1, "milliseconds": 1}, "2022-01-01 01:00:00.001"), | ||
({"days": 1, "milliseconds": 1}, "2022-01-02 00:00:00.001"), | ||
({"weeks": 1, "milliseconds": 1}, "2022-01-08 00:00:00.001"), | ||
({"months": 1, "milliseconds": 1}, "2022-02-01 00:00:00.001"), | ||
({"years": 1, "milliseconds": 1}, "2023-01-01 00:00:00.001"), | ||
], | ||
) | ||
def test_milliseconds_combination(self, offset_kwargs, expected_arg): | ||
# GH 49897 | ||
offset = DateOffset(**offset_kwargs) | ||
ts = Timestamp("2022-01-01") | ||
result = ts + offset | ||
expected = Timestamp(expected_arg) | ||
|
||
assert result == expected | ||
|
||
def test_offset_invalid_arguments(self): | ||
msg = "^Invalid argument/s or bad combination of arguments" | ||
with pytest.raises(ValueError, match=msg): | ||
DateOffset(picoseconds=1) | ||
|
||
|
||
class TestOffsetNames: | ||
def test_get_offset_name(self): | ||
|
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.
is there a test that hits this?
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.
Actually, ever since minutes was added to
kwds_use_relativedelta
, and milliseconds is converted to microseconds, the only case where you raise is for invalid argsSo it would be something like:
Does it make sense?
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.
yeah looks good - if we're adding code, let's make sure it's covered