diff --git a/pandas/tests/tseries/offsets/test_business_month.py b/pandas/tests/tseries/offsets/test_business_month.py index 3f537fc450764..bb2049fd35489 100644 --- a/pandas/tests/tseries/offsets/test_business_month.py +++ b/pandas/tests/tseries/offsets/test_business_month.py @@ -7,6 +7,7 @@ import pytest +import pandas as pd from pandas.tests.tseries.offsets.common import ( Base, assert_is_on_offset, @@ -19,6 +20,29 @@ ) +@pytest.mark.parametrize("n", [-2, 1]) +@pytest.mark.parametrize( + "cls", + [ + BMonthBegin, + BMonthEnd, + ], +) +def test_apply_index(cls, n): + offset = cls(n=n) + rng = pd.date_range(start="1/1/2000", periods=100000, freq="T") + ser = pd.Series(rng) + + res = rng + offset + assert res.freq is None # not retained + assert res[0] == rng[0] + offset + assert res[-1] == rng[-1] + offset + res2 = ser + offset + # apply_index is only for indexes, not series, so no res2_v2 + assert res2.iloc[0] == ser.iloc[0] + offset + assert res2.iloc[-1] == ser.iloc[-1] + offset + + class TestBMonthBegin(Base): _offset = BMonthBegin diff --git a/pandas/tests/tseries/offsets/test_yqm_offsets.py b/pandas/tests/tseries/offsets/test_index.py similarity index 84% rename from pandas/tests/tseries/offsets/test_yqm_offsets.py rename to pandas/tests/tseries/offsets/test_index.py index 39b88074a6883..ad3478b319898 100644 --- a/pandas/tests/tseries/offsets/test_yqm_offsets.py +++ b/pandas/tests/tseries/offsets/test_index.py @@ -1,9 +1,12 @@ """ -Tests for Year, Quarter, and Month-based DateOffset subclasses +Tests for offset behavior with indices. """ import pytest -import pandas as pd +from pandas import ( + Series, + date_range, +) from pandas.tseries.offsets import ( BMonthBegin, @@ -41,8 +44,8 @@ ) def test_apply_index(cls, n): offset = cls(n=n) - rng = pd.date_range(start="1/1/2000", periods=100000, freq="T") - ser = pd.Series(rng) + rng = date_range(start="1/1/2000", periods=100000, freq="T") + ser = Series(rng) res = rng + offset assert res.freq is None # not retained