-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Updating and re-opening PR #48275 #50542
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
4e4f72e
01c824c
bb8856e
caa3f99
0a87cbe
74f171b
3dd874a
e2f2818
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 |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
from pandas.errors import PerformanceWarning | ||
|
||
from pandas import ( | ||
DataFrame, | ||
DatetimeIndex, | ||
Series, | ||
date_range, | ||
|
@@ -1061,6 +1062,38 @@ def test_construct_int_arg_no_kwargs_assumed_days(n): | |
assert result == expected | ||
|
||
|
||
def test_offset_multiplication(): | ||
# GH#47953 | ||
mo1 = DateOffset(months=1) | ||
mo2 = DateOffset(months=2) | ||
|
||
startscalar = Timestamp("2020-01-30") | ||
startarray = Series([Timestamp("2020-01-30")]) | ||
|
||
resultscalar1 = startscalar + (mo1 * 2) | ||
resultscalar2 = startscalar + mo2 | ||
resultarray1 = startarray + (mo1 * 2) | ||
resultarray2 = startarray + mo2 | ||
|
||
expectedscalar = Timestamp("2020-03-30") | ||
expectedarray = Series([Timestamp("2020-03-30")]) | ||
assert resultscalar1 == expectedscalar | ||
assert resultscalar2 == expectedscalar | ||
tm.assert_series_equal(resultarray1, expectedarray) | ||
tm.assert_series_equal(resultarray2, expectedarray) | ||
|
||
df = DataFrame({"T": [Timestamp("2019-04-30")], "D": [DateOffset(months=1)]}) | ||
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. This should be a separate test. |
||
frameresult1 = df["T"] + 26 * df["D"] | ||
df2 = DataFrame( | ||
{ | ||
"T": [Timestamp("2019-04-30"), Timestamp("2019-04-30")], | ||
"D": [DateOffset(months=1), DateOffset(months=1)], | ||
} | ||
) | ||
frameresult2 = df2["T"] + 26 * df2["D"] | ||
assert frameresult1[0] == frameresult2[0] | ||
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. any chance they could both be checked against some expected output? otherwise perhaps in the future they could both change and become wrong? 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, I can do that. I haven't had much time to work on this recently, but I'll try to handle all these comments when I find some time to deal with them. 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, no hurry, thanks! |
||
|
||
|
||
@pytest.mark.parametrize( | ||
"offset, expected", | ||
[ | ||
|
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.
could these be parametrised over?