Skip to content

Commit 7decf16

Browse files
committed
Add array into the boy and add parameter freq
1 parent 91c25c8 commit 7decf16

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

pandas/tests/arithmetic/test_datetime64.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,37 +1435,38 @@ def test_dt64arr_add_sub_offset_ndarray(self, tz_naive_fixture,
14351435
expected = tm.box_expected(expected, box_with_array)
14361436
tm.assert_equal(res, expected)
14371437

1438-
@pytest.mark.parametrize("box", [pd.Index, pd.Series, pd.DataFrame])
1439-
@pytest.mark.parametrize("op, offset, exp", [
1438+
@pytest.mark.parametrize("op, offset, exp, exp_freq", [
14401439
('__add__', pd.DateOffset(months=3, days=10),
14411440
[Timestamp('2014-04-11'), Timestamp('2015-04-11'),
1442-
Timestamp('2016-04-11'), Timestamp('2017-04-11')]),
1441+
Timestamp('2016-04-11'), Timestamp('2017-04-11')],
1442+
None),
14431443
('__add__', pd.DateOffset(months=3),
14441444
[Timestamp('2014-04-01'), Timestamp('2015-04-01'),
1445-
Timestamp('2016-04-01'), Timestamp('2017-04-01')]),
1445+
Timestamp('2016-04-01'), Timestamp('2017-04-01')],
1446+
"AS-APR"),
14461447
('__sub__', pd.DateOffset(months=3, days=10),
14471448
[Timestamp('2013-09-21'), Timestamp('2014-09-21'),
1448-
Timestamp('2015-09-21'), Timestamp('2016-09-21')]),
1449+
Timestamp('2015-09-21'), Timestamp('2016-09-21')],
1450+
None),
14491451
('__sub__', pd.DateOffset(months=3),
14501452
[Timestamp('2013-10-01'), Timestamp('2014-10-01'),
1451-
Timestamp('2015-10-01'), Timestamp('2016-10-01')])
1452-
1453+
Timestamp('2015-10-01'), Timestamp('2016-10-01')],
1454+
"AS-OCT")
14531455
])
1454-
def test_dti_add_sub_nonzero_mth_offset(self, op, offset, exp,
1456+
def test_dti_add_sub_nonzero_mth_offset(self, op, offset,
1457+
exp, exp_freq,
14551458
tz_aware_fixture,
1456-
box):
1459+
box_with_array):
14571460
# GH 26258
14581461
tz = tz_aware_fixture
14591462
date = date_range(start='01 Jan 2014', end='01 Jan 2017', freq='AS',
14601463
tz=tz)
1461-
date = (tm.box_expected(date, box) if box is not pd.DataFrame
1462-
else tm.box_expected(date, box, False))
1464+
date = tm.box_expected(date, box_with_array, False)
14631465
mth = getattr(date, op)
14641466
result = mth(offset)
14651467

1466-
expected = pd.Index(exp, tz=tz)
1467-
expected = (tm.box_expected(expected, box) if box is not pd.DataFrame
1468-
else tm.box_expected(expected, box, False))
1468+
expected = pd.DatetimeIndex(exp, tz=tz, freq=exp_freq)
1469+
expected = tm.box_expected(expected, box_with_array, False)
14691470
tm.assert_equal(result, expected)
14701471

14711472

0 commit comments

Comments
 (0)