Skip to content

[TEST] Add two more parameters to the test_dti_add_sub_nonzero_mth_offset #26392

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
merged 2 commits into from
May 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions pandas/tests/arithmetic/test_datetime64.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,27 +1435,39 @@ def test_dt64arr_add_sub_offset_ndarray(self, tz_naive_fixture,
expected = tm.box_expected(expected, box_with_array)
tm.assert_equal(res, expected)

@pytest.mark.parametrize("op, offset, exp", [
@pytest.mark.parametrize("op, offset, exp, exp_freq", [
('__add__', pd.DateOffset(months=3, days=10),
DatetimeIndex([Timestamp('2014-04-11'), Timestamp('2015-04-11'),
Timestamp('2016-04-11'), Timestamp('2017-04-11')])),
[Timestamp('2014-04-11'), Timestamp('2015-04-11'),
Timestamp('2016-04-11'), Timestamp('2017-04-11')],
None),
('__add__', pd.DateOffset(months=3),
DatetimeIndex([Timestamp('2014-04-01'), Timestamp('2015-04-01'),
Timestamp('2016-04-01'), Timestamp('2017-04-01')])),
[Timestamp('2014-04-01'), Timestamp('2015-04-01'),
Timestamp('2016-04-01'), Timestamp('2017-04-01')],
"AS-APR"),
('__sub__', pd.DateOffset(months=3, days=10),
DatetimeIndex([Timestamp('2013-09-21'), Timestamp('2014-09-21'),
Timestamp('2015-09-21'), Timestamp('2016-09-21')])),
[Timestamp('2013-09-21'), Timestamp('2014-09-21'),
Timestamp('2015-09-21'), Timestamp('2016-09-21')],
None),
('__sub__', pd.DateOffset(months=3),
DatetimeIndex([Timestamp('2013-10-01'), Timestamp('2014-10-01'),
Timestamp('2015-10-01'), Timestamp('2016-10-01')]))

[Timestamp('2013-10-01'), Timestamp('2014-10-01'),
Timestamp('2015-10-01'), Timestamp('2016-10-01')],
"AS-OCT")
])
def test_dti_add_sub_nonzero_mth_offset(self, op, offset, exp):
def test_dti_add_sub_nonzero_mth_offset(self, op, offset,
exp, exp_freq,
tz_aware_fixture,
box_with_array):
# GH 26258
date = date_range(start='01 Jan 2014', end='01 Jan 2017', freq='AS')
tz = tz_aware_fixture
date = date_range(start='01 Jan 2014', end='01 Jan 2017', freq='AS',
tz=tz)
date = tm.box_expected(date, box_with_array, False)
mth = getattr(date, op)
result = mth(offset)
tm.assert_equal(result, exp)

expected = pd.DatetimeIndex(exp, tz=tz, freq=exp_freq)
expected = tm.box_expected(expected, box_with_array, False)
tm.assert_equal(result, expected)


class TestDatetime64OverflowHandling:
Expand Down