diff --git a/doc/source/reference/offset_frequency.rst b/doc/source/reference/offset_frequency.rst index e6271a7806706..c5ed8d718bfb7 100644 --- a/doc/source/reference/offset_frequency.rst +++ b/doc/source/reference/offset_frequency.rst @@ -655,7 +655,7 @@ Properties BQuarterEnd.normalize BQuarterEnd.rule_code BQuarterEnd.n - BQuarterEnd.startingMonth + BQuarterEnd.month Methods ~~~~~~~ @@ -690,7 +690,7 @@ Properties BQuarterBegin.normalize BQuarterBegin.rule_code BQuarterBegin.n - BQuarterBegin.startingMonth + BQuarterBegin.month Methods ~~~~~~~ @@ -725,7 +725,7 @@ Properties QuarterEnd.normalize QuarterEnd.rule_code QuarterEnd.n - QuarterEnd.startingMonth + QuarterEnd.month Methods ~~~~~~~ @@ -760,7 +760,7 @@ Properties QuarterBegin.normalize QuarterBegin.rule_code QuarterBegin.n - QuarterBegin.startingMonth + QuarterBegin.month Methods ~~~~~~~ diff --git a/doc/source/whatsnew/v0.18.0.rst b/doc/source/whatsnew/v0.18.0.rst index 829c04dac9f2d..349a718cf2172 100644 --- a/doc/source/whatsnew/v0.18.0.rst +++ b/doc/source/whatsnew/v0.18.0.rst @@ -686,6 +686,7 @@ when it is an anchor point (e.g., a quarter start date), and otherwise roll forward to the next anchor point. .. ipython:: python + :okwarning: d = pd.Timestamp('2014-02-01') d @@ -706,6 +707,7 @@ This behavior has been corrected in version 0.18.0, which is consistent with other anchored offsets like ``MonthBegin`` and ``YearBegin``. .. ipython:: python + :okwarning: d = pd.Timestamp('2014-02-15') d + pd.offsets.QuarterBegin(n=0, startingMonth=2) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 38a1802340c69..618045b6ffa7d 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -458,6 +458,36 @@ with a :class:`MultiIndex` in the result. This can lead to a perceived duplicati df.groupby('label1').rolling(1).sum() +.. _whatsnew_130.notable_bug_fixes.quarterbegin_default_anchor: + +Changed default periods in :class:`~pandas.tseries.offsets.QuarterBegin` and :class:`~pandas.tseries.offsets.BQuarterBegin` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Quarter-based time offset classes :class:`~pandas.tseries.offsets.QuarterEnd`, +:class:`~pandas.tseries.offsets.QuarterBegin`, :class:`~pandas.tseries.offsets.BQuarterEnd`, +:class:`~pandas.tseries.offsets.BQuarterBegin` now use ``month`` instead of ``startingMonth`` +as a time anchor parameter (:issue:`5307`). The default value for :class:`~pandas.tseries.offsets.QuarterBegin` +and :class:`~pandas.tseries.offsets.BQuarterBegin` is now 1 (January) instead of 3 (March), +as a result these offsets are aligned with standard calendar quarters (:issue:`8435`). + +*pandas 1.2.x* + +.. code-block:: ipython + + In [1]: pd.Timestamp(2014, 10, 10) + pd.tseries.offsets.QuarterBegin() + Out[2]: Timestamp('2014-12-01 00:00:00') + In [3]: pd.Timestamp(2014, 10, 10) + pd.tseries.offsets.BQuarterBegin() + Out[4]: Timestamp('2014-12-01 00:00:00') + +*pandas 1.3.0* + +.. code-block:: ipython + + In [1]: pd.Timestamp(2014, 10, 10) + pd.tseries.offsets.QuarterBegin() + Out[2]: Timestamp('2015-01-01 00:00:00') + In [3]: pd.Timestamp(2014, 10, 10) + pd.tseries.offsets.BQuarterBegin() + Out[4]: Timestamp('2015-01-01 00:00:00') + .. _whatsnew_130.api_breaking.deps: Increased minimum versions for dependencies @@ -570,6 +600,7 @@ Deprecations - Deprecated allowing partial failure in :meth:`Series.transform` and :meth:`DataFrame.transform` when ``func`` is list-like or dict-like and raises anything but ``TypeError``; ``func`` raising anything but a ``TypeError`` will raise in a future version (:issue:`40211`) - Deprecated support for ``np.ma.mrecords.MaskedRecords`` in the :class:`DataFrame` constructor, pass ``{name: data[name] for name in data.dtype.names}`` instead (:issue:`40363`) - Deprecated the use of ``**kwargs`` in :class:`.ExcelWriter`; use the keyword argument ``engine_kwargs`` instead (:issue:`40430`) +- Deprecated the ``startingMonth`` keyword in quarter-based offsets :class:`QuarterBegin`, :class:`QuarterEnd`, :class:`BQuarterBegin`, :class:`BQuarterEnd`; use ``month`` instead (:issue:`5307`) - Deprecated the ``level`` keyword for :class:`DataFrame` and :class:`Series` aggregations; use groupby instead (:issue:`39983`) .. --------------------------------------------------------------------------- @@ -625,6 +656,7 @@ Datetimelike - Bug in :meth:`Timedelta.round`, :meth:`Timedelta.floor`, :meth:`Timedelta.ceil` for values near the implementation bounds of :class:`Timedelta` (:issue:`38964`) - Bug in :func:`date_range` incorrectly creating :class:`DatetimeIndex` containing ``NaT`` instead of raising ``OutOfBoundsDatetime`` in corner cases (:issue:`24124`) - Bug in :func:`infer_freq` incorrectly fails to infer 'H' frequency of :class:`DatetimeIndex` if the latter has a timezone and crosses DST boundaries (:issue:`39556`) +- Bug in offsets :class:`QuarterBegin` and :class:`BQuarterBegin` returning days that are not conventional quarter beginnings (:issue:`8435`) Timedelta ^^^^^^^^^ diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 4e6e5485b2ade..be9d4a7ac04c6 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -1986,52 +1986,88 @@ cdef class YearBegin(YearOffset): # Quarter-Based Offset Classes cdef class QuarterOffset(SingleConstructorOffset): - _attributes = tuple(["n", "normalize", "startingMonth"]) - # TODO: Consider combining QuarterOffset and YearOffset __init__ at some - # point. Also apply_index, is_on_offset, rule_code if - # startingMonth vs month attr names are resolved + """ + Base for quarter-based offset classes. + + Parameters + ---------- + n : int, default 1 + Number of quarters to offset. + normalize : bool, default False + If true, the time component of the resulting date-time is converted + to 00:00:00, i.e. midnight (the start, not the end of date-time). + month : int + The calendar month number (1 for January) of the beginning or ending + month in a custom-defined quarter to be used as an offset. + + .. versionadded:: 1.3.0 + startingMonth : int + The calendar month number (1 for January) of the beginning or ending + month in a custom-defined quarter to be used as an offset. + + .. deprecated:: 1.3.0 + """ - # FIXME: python annotations here breaks things - # _default_starting_month: int - # _from_name_starting_month: int + _attributes = tuple(["n", "normalize", "month"]) + # TODO: Consider combining QuarterOffset and YearOffset __init__ at some + # point. Also apply_index, is_on_offset, rule_code. cdef readonly: - int startingMonth + int month - def __init__(self, n=1, normalize=False, startingMonth=None): + def __init__(self, n: int=1, normalize: bool=False, month: int=None, + *, startingMonth: int=None): + # GH#5307 startingMonth retained for backwards compatibility BaseOffset.__init__(self, n, normalize) - if startingMonth is None: - startingMonth = self._default_starting_month - self.startingMonth = startingMonth + # GH#5307 startingMonth retained for backwards compatibility + if month and startingMonth and month != startingMonth: + raise TypeError("Offset received both month and startingMonth") + elif month is None and startingMonth is not None: + warnings.warn( + "startingMonth is deprecated, use month instead.", + FutureWarning, stacklevel=2 + ) + month = startingMonth + + month = month if month is not None else self._default_month + self.month = month + + if month < 1 or month > 12: + raise ValueError("Month must go from 1 to 12.") cpdef __setstate__(self, state): - self.startingMonth = state.pop("startingMonth") + try: + self.month = state.pop("month") + except: + # Necessary for read_pickle of data pickled with pre-1.3 pandas + self.month = state.pop("startingMonth") self.n = state.pop("n") self.normalize = state.pop("normalize") + self._cache = {} @classmethod def _from_name(cls, suffix=None): kwargs = {} if suffix: - kwargs["startingMonth"] = MONTH_TO_CAL_NUM[suffix] + kwargs["month"] = MONTH_TO_CAL_NUM[suffix] else: - if cls._from_name_starting_month is not None: - kwargs["startingMonth"] = cls._from_name_starting_month + if cls._from_name_month is not None: + kwargs["month"] = cls._from_name_month return cls(**kwargs) @property def rule_code(self) -> str: - month = MONTH_ALIASES[self.startingMonth] + month = MONTH_ALIASES[self.month] return f"{self._prefix}-{month}" def is_anchored(self) -> bool: - return self.n == 1 and self.startingMonth is not None + return self.n == 1 and self.month is not None def is_on_offset(self, dt: datetime) -> bool: if self.normalize and not _is_normalized(dt): return False - mod_month = (dt.month - self.startingMonth) % 3 + mod_month = (dt.month - self.month) % 3 return mod_month == 0 and dt.day == self._get_offset_day(dt) @apply_wraps @@ -2041,9 +2077,9 @@ cdef class QuarterOffset(SingleConstructorOffset): # Then find the month in that quarter containing an is_on_offset date for # self. `months_since` is the number of months to shift other.month # to get to this on-offset month. - months_since = other.month % 3 - self.startingMonth % 3 + months_since = other.month % 3 - self.month % 3 qtrs = roll_qtrday( - other, self.n, self.startingMonth, day_opt=self._day_opt, modby=3 + other, self.n, self.month, day_opt=self._day_opt, modby=3 ) months = qtrs * 3 - months_since return shift_month(other, months, self._day_opt) @@ -2055,35 +2091,53 @@ cdef class QuarterOffset(SingleConstructorOffset): @apply_array_wraps def _apply_array(self, dtarr): shifted = shift_quarters( - dtarr.view("i8"), self.n, self.startingMonth, self._day_opt + dtarr.view("i8"), self.n, self.month, self._day_opt ) return shifted cdef class BQuarterEnd(QuarterOffset): """ - DateOffset increments between the last business day of each Quarter. + DateOffset increments between the last business day of each quarter. - startingMonth = 1 corresponds to dates like 1/31/2007, 4/30/2007, ... - startingMonth = 2 corresponds to dates like 2/28/2007, 5/31/2007, ... - startingMonth = 3 corresponds to dates like 3/30/2007, 6/29/2007, ... + month = 1 corresponds to dates like 1/31/2007, 4/30/2007, ... + month = 2 corresponds to dates like 2/28/2007, 5/31/2007, ... + month = 3 corresponds to dates like 3/30/2007, 6/29/2007, ... + + Parameters + ---------- + n : int, default 1 + Number of business quarters to offset. + normalize : bool, default False + If true, the time component of the resulting date-time is converted + to 00:00:00, i.e. midnight (the start, not the end of date-time). + month : int, default 3 + The calendar month number (3 for March) of the last month + in a custom-defined business quarter to be used as an offset. + + .. versionadded:: 1.3.0 + startingMonth : int, default 3 + The calendar month number (3 for March) of the last month + in a custom-defined business quarter to be used as an offset. + + .. deprecated:: 1.3.0 Examples -------- - >>> from pandas.tseries.offset import BQuarterEnd + >>> from pandas.tseries.offsets import BQuarterEnd >>> ts = pd.Timestamp('2020-05-24 05:01:15') >>> ts + BQuarterEnd() Timestamp('2020-06-30 05:01:15') >>> ts + BQuarterEnd(2) Timestamp('2020-09-30 05:01:15') - >>> ts + BQuarterEnd(1, startingMonth=2) + >>> ts + BQuarterEnd(1, month=2) Timestamp('2020-05-29 05:01:15') - >>> ts + BQuarterEnd(startingMonth=2) + >>> ts + BQuarterEnd(month=2) Timestamp('2020-05-29 05:01:15') """ _output_name = "BusinessQuarterEnd" - _default_starting_month = 3 - _from_name_starting_month = 12 + _default_month = 3 + _from_name_month = 3 _prefix = "BQ" _day_opt = "business_end" @@ -2092,26 +2146,44 @@ cdef class BQuarterBegin(QuarterOffset): """ DateOffset increments between the first business day of each Quarter. - startingMonth = 1 corresponds to dates like 1/01/2007, 4/01/2007, ... - startingMonth = 2 corresponds to dates like 2/01/2007, 5/01/2007, ... - startingMonth = 3 corresponds to dates like 3/01/2007, 6/01/2007, ... + month = 1 corresponds to dates like 1/01/2007, 4/01/2007, ... + month = 2 corresponds to dates like 2/01/2007, 5/01/2007, ... + month = 3 corresponds to dates like 3/01/2007, 6/01/2007, ... + + Parameters + ---------- + n : int, default 1 + Number of business quarters to offset. + normalize : bool, default False + If true, the time component of the resulting date-time is converted + to 00:00:00, i.e. midnight (the start, not the end of date-time). + month : int, default 1 + The calendar month number (1 for January) of the first month + in a custom-defined business quarter to be used as an offset. + + .. versionadded:: 1.3.0 + startingMonth : int, default 1 + The calendar month number (1 for January) of the first month + in a custom-defined business quarter to be used as an offset. + + .. deprecated:: 1.3.0 Examples -------- - >>> from pandas.tseries.offset import BQuarterBegin + >>> from pandas.tseries.offsets import BQuarterBegin >>> ts = pd.Timestamp('2020-05-24 05:01:15') >>> ts + BQuarterBegin() Timestamp('2020-06-01 05:01:15') >>> ts + BQuarterBegin(2) Timestamp('2020-09-01 05:01:15') - >>> ts + BQuarterBegin(startingMonth=2) + >>> ts + BQuarterBegin(month=2) Timestamp('2020-08-03 05:01:15') >>> ts + BQuarterBegin(-1) Timestamp('2020-03-02 05:01:15') """ _output_name = "BusinessQuarterBegin" - _default_starting_month = 3 - _from_name_starting_month = 1 + _default_month = 1 + _from_name_month = 1 _prefix = "BQS" _day_opt = "business_start" @@ -2120,34 +2192,73 @@ cdef class QuarterEnd(QuarterOffset): """ DateOffset increments between Quarter end dates. - startingMonth = 1 corresponds to dates like 1/31/2007, 4/30/2007, ... - startingMonth = 2 corresponds to dates like 2/28/2007, 5/31/2007, ... - startingMonth = 3 corresponds to dates like 3/31/2007, 6/30/2007, ... + month = 1 corresponds to dates like 1/31/2007, 4/30/2007, ... + month = 2 corresponds to dates like 2/28/2007, 5/31/2007, ... + month = 3 corresponds to dates like 3/31/2007, 6/30/2007, ... + + Parameters + ---------- + n : int, default 1 + Number of quarters to offset. + normalize : bool, default False + If true, the time component of the resulting date-time is converted + to 00:00:00, i.e. midnight (the start, not the end of date-time). + month : int, default 3 + The calendar month number (3 for March) of the last month + in a custom-defined quarter to be used as an offset. + + .. versionadded:: 1.3.0 + startingMonth : int, default 3 + The calendar month number (3 for March) of the last month + in a custom-defined quarter to be used as an offset. + + .. deprecated:: 1.3.0 """ - _default_starting_month = 3 + _default_month = 3 + _from_name_month = 3 _prefix = "Q" _day_opt = "end" cdef readonly: int _period_dtype_code - def __init__(self, n=1, normalize=False, startingMonth=None): + def __init__(self, n: int=1, normalize: bool=False, month: int=None, + *, startingMonth: int=None): # GH#5307 backwards compatibility # Because QuarterEnd can be the freq for a Period, define its # _period_dtype_code at construction for performance - QuarterOffset.__init__(self, n, normalize, startingMonth) - self._period_dtype_code = PeriodDtypeCode.Q_DEC + self.startingMonth % 12 + QuarterOffset.__init__(self, n, normalize, month, + startingMonth=startingMonth) + self._period_dtype_code = PeriodDtypeCode.Q_DEC + self.month % 12 cdef class QuarterBegin(QuarterOffset): """ DateOffset increments between Quarter start dates. - startingMonth = 1 corresponds to dates like 1/01/2007, 4/01/2007, ... - startingMonth = 2 corresponds to dates like 2/01/2007, 5/01/2007, ... - startingMonth = 3 corresponds to dates like 3/01/2007, 6/01/2007, ... + month = 1 corresponds to dates like 1/01/2007, 4/01/2007, ... + month = 2 corresponds to dates like 2/01/2007, 5/01/2007, ... + month = 3 corresponds to dates like 3/01/2007, 6/01/2007, ... + + Parameters + ---------- + n : int, default 1 + Number of quarters to offset. + normalize : bool, default False + If true, the time component of the resulting date-time is converted + to 00:00:00, i.e. midnight (the start, not the end of date-time). + month : int, default 1 + The calendar month number (1 for January) of the first month + in a custom-defined quarter to be used as an offset. + + .. versionadded:: 1.3.0 + startingMonth : int, default 1 + The calendar month number (1 for January) of the first month + in a custom-defined quarter to be used as an offset. + + .. deprecated:: 1.3.0 """ - _default_starting_month = 3 - _from_name_starting_month = 1 + _default_month = 1 + _from_name_month = 1 _prefix = "QS" _day_opt = "start" diff --git a/pandas/conftest.py b/pandas/conftest.py index 3fdde3261bd68..ec24215311915 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -172,7 +172,7 @@ def pytest_collection_modifyitems(items): cls, n=st.integers(-24, 24), normalize=st.booleans(), - startingMonth=st.integers(min_value=1, max_value=12), + month=st.integers(min_value=1, max_value=12), ), ) diff --git a/pandas/tests/arithmetic/test_period.py b/pandas/tests/arithmetic/test_period.py index bb78e29924ba2..58108c93afc6a 100644 --- a/pandas/tests/arithmetic/test_period.py +++ b/pandas/tests/arithmetic/test_period.py @@ -665,7 +665,7 @@ def test_sub_n_gt_1_ticks(self, tick_classes, n): "offset, kwd_name", [ (pd.offsets.YearEnd, "month"), - (pd.offsets.QuarterEnd, "startingMonth"), + (pd.offsets.QuarterEnd, "month"), (pd.offsets.MonthEnd, None), (pd.offsets.Week, "weekday"), ], @@ -839,8 +839,8 @@ def test_pi_add_offset_array(self, box): pi = PeriodIndex([Period("2015Q1"), Period("2016Q2")]) offs = box( [ - pd.offsets.QuarterEnd(n=1, startingMonth=12), - pd.offsets.QuarterEnd(n=-2, startingMonth=12), + pd.offsets.QuarterEnd(n=1, month=12), + pd.offsets.QuarterEnd(n=-2, month=12), ] ) expected = PeriodIndex([Period("2015Q2"), Period("2015Q4")]) @@ -870,8 +870,8 @@ def test_pi_sub_offset_array(self, box): pi = PeriodIndex([Period("2015Q1"), Period("2016Q2")]) other = box( [ - pd.offsets.QuarterEnd(n=1, startingMonth=12), - pd.offsets.QuarterEnd(n=-2, startingMonth=12), + pd.offsets.QuarterEnd(n=1, month=12), + pd.offsets.QuarterEnd(n=-2, month=12), ] ) diff --git a/pandas/tests/indexes/datetimes/test_constructors.py b/pandas/tests/indexes/datetimes/test_constructors.py index ec597b1468904..8c3aa45f0d324 100644 --- a/pandas/tests/indexes/datetimes/test_constructors.py +++ b/pandas/tests/indexes/datetimes/test_constructors.py @@ -1045,16 +1045,12 @@ def test_datetimeindex_constructor_misc(self): assert idx1.freq == idx2.freq idx1 = date_range(start=sdate, end=edate, freq="QS") - idx2 = date_range( - start=sdate, end=edate, freq=offsets.QuarterBegin(startingMonth=1) - ) + idx2 = date_range(start=sdate, end=edate, freq=offsets.QuarterBegin(month=1)) assert len(idx1) == len(idx2) assert idx1.freq == idx2.freq idx1 = date_range(start=sdate, end=edate, freq="BQ") - idx2 = date_range( - start=sdate, end=edate, freq=offsets.BQuarterEnd(startingMonth=12) - ) + idx2 = date_range(start=sdate, end=edate, freq=offsets.BQuarterEnd(month=3)) assert len(idx1) == len(idx2) assert idx1.freq == idx2.freq diff --git a/pandas/tests/indexes/datetimes/test_misc.py b/pandas/tests/indexes/datetimes/test_misc.py index c3736d588601b..c4eac92bf2009 100644 --- a/pandas/tests/indexes/datetimes/test_misc.py +++ b/pandas/tests/indexes/datetimes/test_misc.py @@ -247,7 +247,7 @@ def test_datetimeindex_accessors(self): tm.assert_index_equal(res, exp) def test_datetimeindex_accessors2(self): - dti = date_range(freq="BQ-FEB", start=datetime(1998, 1, 1), periods=4) + dti = date_range(freq="BQ-DEC", start=datetime(1998, 1, 1), periods=4) assert sum(dti.is_quarter_start) == 0 assert sum(dti.is_quarter_end) == 4 diff --git a/pandas/tests/resample/test_period_index.py b/pandas/tests/resample/test_period_index.py index e2b13f6a00677..401a912ec0799 100644 --- a/pandas/tests/resample/test_period_index.py +++ b/pandas/tests/resample/test_period_index.py @@ -130,7 +130,7 @@ def test_basic_downsample(self, simple_period_range_series): "rule,expected_error_msg", [ ("a-dec", ""), - ("q-mar", ""), + ("q-mar", ""), ("M", ""), ("w-thu", ""), ], diff --git a/pandas/tests/scalar/period/test_period.py b/pandas/tests/scalar/period/test_period.py index 3cc81ef851306..f1a97cf599dd1 100644 --- a/pandas/tests/scalar/period/test_period.py +++ b/pandas/tests/scalar/period/test_period.py @@ -198,10 +198,10 @@ def test_period_constructor_offsets(self): assert Period("3/10/12", freq=offsets.Day()) == Period("3/10/12", freq="D") assert Period( - year=2005, quarter=1, freq=offsets.QuarterEnd(startingMonth=12) + year=2005, quarter=1, freq=offsets.QuarterEnd(month=12) ) == Period(year=2005, quarter=1, freq="Q") assert Period( - year=2005, quarter=2, freq=offsets.QuarterEnd(startingMonth=12) + year=2005, quarter=2, freq=offsets.QuarterEnd(month=12) ) == Period(year=2005, quarter=2, freq="Q") assert Period(year=2005, month=3, day=1, freq=offsets.Day()) == Period( @@ -1252,7 +1252,7 @@ def test_sub_n_gt_1_ticks(self, tick_classes, n): "offset, kwd_name", [ (offsets.YearEnd, "month"), - (offsets.QuarterEnd, "startingMonth"), + (offsets.QuarterEnd, "month"), (offsets.MonthEnd, None), (offsets.Week, "weekday"), ], diff --git a/pandas/tests/tseries/offsets/test_dst.py b/pandas/tests/tseries/offsets/test_dst.py index 0ae94b6b57640..2039987e835b4 100644 --- a/pandas/tests/tseries/offsets/test_dst.py +++ b/pandas/tests/tseries/offsets/test_dst.py @@ -159,9 +159,9 @@ def test_springforward_singular(self): YearEnd: ["11/2/2012", "12/31/2012"], BYearBegin: ["11/2/2012", "1/1/2013"], BYearEnd: ["11/2/2012", "12/31/2012"], - QuarterBegin: ["11/2/2012", "12/1/2012"], + QuarterBegin: ["11/2/2012", "1/1/2013"], QuarterEnd: ["11/2/2012", "12/31/2012"], - BQuarterBegin: ["11/2/2012", "12/3/2012"], + BQuarterBegin: ["11/2/2021", "1/3/2022"], BQuarterEnd: ["11/2/2012", "12/31/2012"], Day: ["11/4/2012", "11/4/2012 23:00"], }.items() diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index 3eb3892279832..75aa1a771bff6 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -84,8 +84,8 @@ class TestCommon(Base): "BYearBegin": Timestamp("2011-01-03 09:00:00"), "YearEnd": Timestamp("2011-12-31 09:00:00"), "BYearEnd": Timestamp("2011-12-30 09:00:00"), - "QuarterBegin": Timestamp("2011-03-01 09:00:00"), - "BQuarterBegin": Timestamp("2011-03-01 09:00:00"), + "QuarterBegin": Timestamp("2011-04-01 09:00:00"), + "BQuarterBegin": Timestamp("2011-01-03 09:00:00"), "QuarterEnd": Timestamp("2011-03-31 09:00:00"), "BQuarterEnd": Timestamp("2011-03-31 09:00:00"), "BusinessHour": Timestamp("2011-01-03 10:00:00"), @@ -260,6 +260,7 @@ def test_rollforward(self, offset_types): "Day", "MonthBegin", "SemiMonthBegin", + "QuarterBegin", "YearBegin", "Week", "Hour", @@ -286,6 +287,7 @@ def test_rollforward(self, offset_types): "DateOffset": Timestamp("2011-01-02 00:00:00"), "MonthBegin": Timestamp("2011-02-01 00:00:00"), "SemiMonthBegin": Timestamp("2011-01-15 00:00:00"), + "QuarterBegin": Timestamp("2011-04-01 00:00:00"), "YearBegin": Timestamp("2012-01-01 00:00:00"), "Week": Timestamp("2011-01-08 00:00:00"), "Hour": Timestamp("2011-01-01 00:00:00"), @@ -320,8 +322,7 @@ def test_rollback(self, offset_types): "BYearBegin": Timestamp("2010-01-01 09:00:00"), "YearEnd": Timestamp("2010-12-31 09:00:00"), "BYearEnd": Timestamp("2010-12-31 09:00:00"), - "QuarterBegin": Timestamp("2010-12-01 09:00:00"), - "BQuarterBegin": Timestamp("2010-12-01 09:00:00"), + "BQuarterBegin": Timestamp("2010-10-01 09:00:00"), "QuarterEnd": Timestamp("2010-12-31 09:00:00"), "BQuarterEnd": Timestamp("2010-12-31 09:00:00"), "BusinessHour": Timestamp("2010-12-31 17:00:00"), @@ -338,6 +339,7 @@ def test_rollback(self, offset_types): "Day", "MonthBegin", "SemiMonthBegin", + "QuarterBegin", "YearBegin", "Week", "Hour", @@ -360,6 +362,7 @@ def test_rollback(self, offset_types): "DateOffset": Timestamp("2010-12-31 00:00:00"), "MonthBegin": Timestamp("2010-12-01 00:00:00"), "SemiMonthBegin": Timestamp("2010-12-15 00:00:00"), + "QuarterBegin": Timestamp("2010-10-01 00:00:00"), "YearBegin": Timestamp("2010-01-01 00:00:00"), "Week": Timestamp("2010-12-25 00:00:00"), "Hour": Timestamp("2011-01-01 00:00:00"), @@ -870,3 +873,22 @@ def test_dateoffset_immutable(attribute): msg = "DateOffset objects are immutable" with pytest.raises(AttributeError, match=msg): setattr(offset, attribute, 5) + + +@pytest.mark.parametrize( + "offset_type", + [ + "QuarterBegin", + "QuarterEnd", + "BQuarterBegin", + "BQuarterEnd", + ], +) +def test_startingMonth_deprecation(offset_type): + # GH#5307 + with tm.assert_produces_warning(FutureWarning): + eval(f"offsets.{offset_type}(startingMonth=1)") + + msg = "Offset received both month and startingMonth" + with pytest.raises(TypeError, match=msg): + eval(f"offsets.{offset_type}(startingMonth=1,month=2)") diff --git a/pandas/tests/tseries/offsets/test_yqm_offsets.py b/pandas/tests/tseries/offsets/test_yqm_offsets.py index 260f7368123a4..6f601318b5a3d 100644 --- a/pandas/tests/tseries/offsets/test_yqm_offsets.py +++ b/pandas/tests/tseries/offsets/test_yqm_offsets.py @@ -436,27 +436,27 @@ def test_is_on_offset(self, case): class TestQuarterBegin(Base): def test_repr(self): - expected = "" + expected = "" assert repr(QuarterBegin()) == expected - expected = "" - assert repr(QuarterBegin(startingMonth=3)) == expected - expected = "" - assert repr(QuarterBegin(startingMonth=1)) == expected + expected = "" + assert repr(QuarterBegin(month=3)) == expected + expected = "" + assert repr(QuarterBegin(month=1)) == expected def test_is_anchored(self): - assert QuarterBegin(startingMonth=1).is_anchored() + assert QuarterBegin(month=1).is_anchored() assert QuarterBegin().is_anchored() - assert not QuarterBegin(2, startingMonth=1).is_anchored() + assert not QuarterBegin(2, month=1).is_anchored() def test_offset_corner_case(self): # corner - offset = QuarterBegin(n=-1, startingMonth=1) + offset = QuarterBegin(n=-1, month=1) assert datetime(2010, 2, 1) + offset == datetime(2010, 1, 1) offset_cases = [] offset_cases.append( ( - QuarterBegin(startingMonth=1), + QuarterBegin(month=1), { datetime(2007, 12, 1): datetime(2008, 1, 1), datetime(2008, 1, 1): datetime(2008, 4, 1), @@ -472,7 +472,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - QuarterBegin(startingMonth=2), + QuarterBegin(month=2), { datetime(2008, 1, 1): datetime(2008, 2, 1), datetime(2008, 1, 31): datetime(2008, 2, 1), @@ -488,7 +488,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - QuarterBegin(startingMonth=1, n=0), + QuarterBegin(month=1, n=0), { datetime(2008, 1, 1): datetime(2008, 1, 1), datetime(2008, 12, 1): datetime(2009, 1, 1), @@ -505,7 +505,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - QuarterBegin(startingMonth=1, n=-1), + QuarterBegin(month=1, n=-1), { datetime(2008, 1, 1): datetime(2007, 10, 1), datetime(2008, 1, 31): datetime(2008, 1, 1), @@ -522,7 +522,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - QuarterBegin(startingMonth=1, n=2), + QuarterBegin(month=1, n=2), { datetime(2008, 1, 1): datetime(2008, 7, 1), datetime(2008, 2, 15): datetime(2008, 7, 1), @@ -546,27 +546,27 @@ class TestQuarterEnd(Base): _offset = QuarterEnd def test_repr(self): - expected = "" + expected = "" assert repr(QuarterEnd()) == expected - expected = "" - assert repr(QuarterEnd(startingMonth=3)) == expected - expected = "" - assert repr(QuarterEnd(startingMonth=1)) == expected + expected = "" + assert repr(QuarterEnd(month=3)) == expected + expected = "" + assert repr(QuarterEnd(month=1)) == expected def test_is_anchored(self): - assert QuarterEnd(startingMonth=1).is_anchored() + assert QuarterEnd(month=1).is_anchored() assert QuarterEnd().is_anchored() - assert not QuarterEnd(2, startingMonth=1).is_anchored() + assert not QuarterEnd(2, month=1).is_anchored() def test_offset_corner_case(self): # corner - offset = QuarterEnd(n=-1, startingMonth=1) + offset = QuarterEnd(n=-1, month=1) assert datetime(2010, 2, 1) + offset == datetime(2010, 1, 31) offset_cases = [] offset_cases.append( ( - QuarterEnd(startingMonth=1), + QuarterEnd(month=1), { datetime(2008, 1, 1): datetime(2008, 1, 31), datetime(2008, 1, 31): datetime(2008, 4, 30), @@ -582,7 +582,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - QuarterEnd(startingMonth=2), + QuarterEnd(month=2), { datetime(2008, 1, 1): datetime(2008, 2, 29), datetime(2008, 1, 31): datetime(2008, 2, 29), @@ -598,7 +598,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - QuarterEnd(startingMonth=1, n=0), + QuarterEnd(month=1, n=0), { datetime(2008, 1, 1): datetime(2008, 1, 31), datetime(2008, 1, 31): datetime(2008, 1, 31), @@ -614,7 +614,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - QuarterEnd(startingMonth=1, n=-1), + QuarterEnd(month=1, n=-1), { datetime(2008, 1, 1): datetime(2007, 10, 31), datetime(2008, 1, 31): datetime(2007, 10, 31), @@ -631,7 +631,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - QuarterEnd(startingMonth=1, n=2), + QuarterEnd(month=1, n=2), { datetime(2008, 1, 31): datetime(2008, 7, 31), datetime(2008, 2, 15): datetime(2008, 7, 31), @@ -651,36 +651,36 @@ def test_offset(self, case): assert_offset_equal(offset, base, expected) on_offset_cases = [ - (QuarterEnd(1, startingMonth=1), datetime(2008, 1, 31), True), - (QuarterEnd(1, startingMonth=1), datetime(2007, 12, 31), False), - (QuarterEnd(1, startingMonth=1), datetime(2008, 2, 29), False), - (QuarterEnd(1, startingMonth=1), datetime(2007, 3, 30), False), - (QuarterEnd(1, startingMonth=1), datetime(2007, 3, 31), False), - (QuarterEnd(1, startingMonth=1), datetime(2008, 4, 30), True), - (QuarterEnd(1, startingMonth=1), datetime(2008, 5, 30), False), - (QuarterEnd(1, startingMonth=1), datetime(2008, 5, 31), False), - (QuarterEnd(1, startingMonth=1), datetime(2007, 6, 29), False), - (QuarterEnd(1, startingMonth=1), datetime(2007, 6, 30), False), - (QuarterEnd(1, startingMonth=2), datetime(2008, 1, 31), False), - (QuarterEnd(1, startingMonth=2), datetime(2007, 12, 31), False), - (QuarterEnd(1, startingMonth=2), datetime(2008, 2, 29), True), - (QuarterEnd(1, startingMonth=2), datetime(2007, 3, 30), False), - (QuarterEnd(1, startingMonth=2), datetime(2007, 3, 31), False), - (QuarterEnd(1, startingMonth=2), datetime(2008, 4, 30), False), - (QuarterEnd(1, startingMonth=2), datetime(2008, 5, 30), False), - (QuarterEnd(1, startingMonth=2), datetime(2008, 5, 31), True), - (QuarterEnd(1, startingMonth=2), datetime(2007, 6, 29), False), - (QuarterEnd(1, startingMonth=2), datetime(2007, 6, 30), False), - (QuarterEnd(1, startingMonth=3), datetime(2008, 1, 31), False), - (QuarterEnd(1, startingMonth=3), datetime(2007, 12, 31), True), - (QuarterEnd(1, startingMonth=3), datetime(2008, 2, 29), False), - (QuarterEnd(1, startingMonth=3), datetime(2007, 3, 30), False), - (QuarterEnd(1, startingMonth=3), datetime(2007, 3, 31), True), - (QuarterEnd(1, startingMonth=3), datetime(2008, 4, 30), False), - (QuarterEnd(1, startingMonth=3), datetime(2008, 5, 30), False), - (QuarterEnd(1, startingMonth=3), datetime(2008, 5, 31), False), - (QuarterEnd(1, startingMonth=3), datetime(2007, 6, 29), False), - (QuarterEnd(1, startingMonth=3), datetime(2007, 6, 30), True), + (QuarterEnd(1, month=1), datetime(2008, 1, 31), True), + (QuarterEnd(1, month=1), datetime(2007, 12, 31), False), + (QuarterEnd(1, month=1), datetime(2008, 2, 29), False), + (QuarterEnd(1, month=1), datetime(2007, 3, 30), False), + (QuarterEnd(1, month=1), datetime(2007, 3, 31), False), + (QuarterEnd(1, month=1), datetime(2008, 4, 30), True), + (QuarterEnd(1, month=1), datetime(2008, 5, 30), False), + (QuarterEnd(1, month=1), datetime(2008, 5, 31), False), + (QuarterEnd(1, month=1), datetime(2007, 6, 29), False), + (QuarterEnd(1, month=1), datetime(2007, 6, 30), False), + (QuarterEnd(1, month=2), datetime(2008, 1, 31), False), + (QuarterEnd(1, month=2), datetime(2007, 12, 31), False), + (QuarterEnd(1, month=2), datetime(2008, 2, 29), True), + (QuarterEnd(1, month=2), datetime(2007, 3, 30), False), + (QuarterEnd(1, month=2), datetime(2007, 3, 31), False), + (QuarterEnd(1, month=2), datetime(2008, 4, 30), False), + (QuarterEnd(1, month=2), datetime(2008, 5, 30), False), + (QuarterEnd(1, month=2), datetime(2008, 5, 31), True), + (QuarterEnd(1, month=2), datetime(2007, 6, 29), False), + (QuarterEnd(1, month=2), datetime(2007, 6, 30), False), + (QuarterEnd(1, month=3), datetime(2008, 1, 31), False), + (QuarterEnd(1, month=3), datetime(2007, 12, 31), True), + (QuarterEnd(1, month=3), datetime(2008, 2, 29), False), + (QuarterEnd(1, month=3), datetime(2007, 3, 30), False), + (QuarterEnd(1, month=3), datetime(2007, 3, 31), True), + (QuarterEnd(1, month=3), datetime(2008, 4, 30), False), + (QuarterEnd(1, month=3), datetime(2008, 5, 30), False), + (QuarterEnd(1, month=3), datetime(2008, 5, 31), False), + (QuarterEnd(1, month=3), datetime(2007, 6, 29), False), + (QuarterEnd(1, month=3), datetime(2007, 6, 30), True), ] @pytest.mark.parametrize("case", on_offset_cases) @@ -693,27 +693,27 @@ class TestBQuarterBegin(Base): _offset = BQuarterBegin def test_repr(self): - expected = "" + expected = "" assert repr(BQuarterBegin()) == expected - expected = "" - assert repr(BQuarterBegin(startingMonth=3)) == expected - expected = "" - assert repr(BQuarterBegin(startingMonth=1)) == expected + expected = "" + assert repr(BQuarterBegin(month=3)) == expected + expected = "" + assert repr(BQuarterBegin(month=1)) == expected def test_is_anchored(self): - assert BQuarterBegin(startingMonth=1).is_anchored() + assert BQuarterBegin(month=1).is_anchored() assert BQuarterBegin().is_anchored() - assert not BQuarterBegin(2, startingMonth=1).is_anchored() + assert not BQuarterBegin(2, month=1).is_anchored() def test_offset_corner_case(self): # corner - offset = BQuarterBegin(n=-1, startingMonth=1) + offset = BQuarterBegin(n=-1, month=1) assert datetime(2007, 4, 3) + offset == datetime(2007, 4, 2) offset_cases = [] offset_cases.append( ( - BQuarterBegin(startingMonth=1), + BQuarterBegin(month=1), { datetime(2008, 1, 1): datetime(2008, 4, 1), datetime(2008, 1, 31): datetime(2008, 4, 1), @@ -736,7 +736,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - BQuarterBegin(startingMonth=2), + BQuarterBegin(month=2), { datetime(2008, 1, 1): datetime(2008, 2, 1), datetime(2008, 1, 31): datetime(2008, 2, 1), @@ -755,7 +755,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - BQuarterBegin(startingMonth=1, n=0), + BQuarterBegin(month=1, n=0), { datetime(2008, 1, 1): datetime(2008, 1, 1), datetime(2007, 12, 31): datetime(2008, 1, 1), @@ -775,7 +775,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - BQuarterBegin(startingMonth=1, n=-1), + BQuarterBegin(month=1, n=-1), { datetime(2008, 1, 1): datetime(2007, 10, 1), datetime(2008, 1, 31): datetime(2008, 1, 1), @@ -794,7 +794,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - BQuarterBegin(startingMonth=1, n=2), + BQuarterBegin(month=1, n=2), { datetime(2008, 1, 1): datetime(2008, 7, 1), datetime(2008, 1, 15): datetime(2008, 7, 1), @@ -818,27 +818,27 @@ class TestBQuarterEnd(Base): _offset = BQuarterEnd def test_repr(self): - expected = "" + expected = "" assert repr(BQuarterEnd()) == expected - expected = "" - assert repr(BQuarterEnd(startingMonth=3)) == expected - expected = "" - assert repr(BQuarterEnd(startingMonth=1)) == expected + expected = "" + assert repr(BQuarterEnd(month=3)) == expected + expected = "" + assert repr(BQuarterEnd(month=1)) == expected def test_is_anchored(self): - assert BQuarterEnd(startingMonth=1).is_anchored() + assert BQuarterEnd(month=1).is_anchored() assert BQuarterEnd().is_anchored() - assert not BQuarterEnd(2, startingMonth=1).is_anchored() + assert not BQuarterEnd(2, month=1).is_anchored() def test_offset_corner_case(self): # corner - offset = BQuarterEnd(n=-1, startingMonth=1) + offset = BQuarterEnd(n=-1, month=1) assert datetime(2010, 1, 31) + offset == datetime(2010, 1, 29) offset_cases = [] offset_cases.append( ( - BQuarterEnd(startingMonth=1), + BQuarterEnd(month=1), { datetime(2008, 1, 1): datetime(2008, 1, 31), datetime(2008, 1, 31): datetime(2008, 4, 30), @@ -854,7 +854,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - BQuarterEnd(startingMonth=2), + BQuarterEnd(month=2), { datetime(2008, 1, 1): datetime(2008, 2, 29), datetime(2008, 1, 31): datetime(2008, 2, 29), @@ -870,7 +870,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - BQuarterEnd(startingMonth=1, n=0), + BQuarterEnd(month=1, n=0), { datetime(2008, 1, 1): datetime(2008, 1, 31), datetime(2008, 1, 31): datetime(2008, 1, 31), @@ -886,7 +886,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - BQuarterEnd(startingMonth=1, n=-1), + BQuarterEnd(month=1, n=-1), { datetime(2008, 1, 1): datetime(2007, 10, 31), datetime(2008, 1, 31): datetime(2007, 10, 31), @@ -902,7 +902,7 @@ def test_offset_corner_case(self): offset_cases.append( ( - BQuarterEnd(startingMonth=1, n=2), + BQuarterEnd(month=1, n=2), { datetime(2008, 1, 31): datetime(2008, 7, 31), datetime(2008, 2, 15): datetime(2008, 7, 31), @@ -922,33 +922,33 @@ def test_offset(self, case): assert_offset_equal(offset, base, expected) on_offset_cases = [ - (BQuarterEnd(1, startingMonth=1), datetime(2008, 1, 31), True), - (BQuarterEnd(1, startingMonth=1), datetime(2007, 12, 31), False), - (BQuarterEnd(1, startingMonth=1), datetime(2008, 2, 29), False), - (BQuarterEnd(1, startingMonth=1), datetime(2007, 3, 30), False), - (BQuarterEnd(1, startingMonth=1), datetime(2007, 3, 31), False), - (BQuarterEnd(1, startingMonth=1), datetime(2008, 4, 30), True), - (BQuarterEnd(1, startingMonth=1), datetime(2008, 5, 30), False), - (BQuarterEnd(1, startingMonth=1), datetime(2007, 6, 29), False), - (BQuarterEnd(1, startingMonth=1), datetime(2007, 6, 30), False), - (BQuarterEnd(1, startingMonth=2), datetime(2008, 1, 31), False), - (BQuarterEnd(1, startingMonth=2), datetime(2007, 12, 31), False), - (BQuarterEnd(1, startingMonth=2), datetime(2008, 2, 29), True), - (BQuarterEnd(1, startingMonth=2), datetime(2007, 3, 30), False), - (BQuarterEnd(1, startingMonth=2), datetime(2007, 3, 31), False), - (BQuarterEnd(1, startingMonth=2), datetime(2008, 4, 30), False), - (BQuarterEnd(1, startingMonth=2), datetime(2008, 5, 30), True), - (BQuarterEnd(1, startingMonth=2), datetime(2007, 6, 29), False), - (BQuarterEnd(1, startingMonth=2), datetime(2007, 6, 30), False), - (BQuarterEnd(1, startingMonth=3), datetime(2008, 1, 31), False), - (BQuarterEnd(1, startingMonth=3), datetime(2007, 12, 31), True), - (BQuarterEnd(1, startingMonth=3), datetime(2008, 2, 29), False), - (BQuarterEnd(1, startingMonth=3), datetime(2007, 3, 30), True), - (BQuarterEnd(1, startingMonth=3), datetime(2007, 3, 31), False), - (BQuarterEnd(1, startingMonth=3), datetime(2008, 4, 30), False), - (BQuarterEnd(1, startingMonth=3), datetime(2008, 5, 30), False), - (BQuarterEnd(1, startingMonth=3), datetime(2007, 6, 29), True), - (BQuarterEnd(1, startingMonth=3), datetime(2007, 6, 30), False), + (BQuarterEnd(1, month=1), datetime(2008, 1, 31), True), + (BQuarterEnd(1, month=1), datetime(2007, 12, 31), False), + (BQuarterEnd(1, month=1), datetime(2008, 2, 29), False), + (BQuarterEnd(1, month=1), datetime(2007, 3, 30), False), + (BQuarterEnd(1, month=1), datetime(2007, 3, 31), False), + (BQuarterEnd(1, month=1), datetime(2008, 4, 30), True), + (BQuarterEnd(1, month=1), datetime(2008, 5, 30), False), + (BQuarterEnd(1, month=1), datetime(2007, 6, 29), False), + (BQuarterEnd(1, month=1), datetime(2007, 6, 30), False), + (BQuarterEnd(1, month=2), datetime(2008, 1, 31), False), + (BQuarterEnd(1, month=2), datetime(2007, 12, 31), False), + (BQuarterEnd(1, month=2), datetime(2008, 2, 29), True), + (BQuarterEnd(1, month=2), datetime(2007, 3, 30), False), + (BQuarterEnd(1, month=2), datetime(2007, 3, 31), False), + (BQuarterEnd(1, month=2), datetime(2008, 4, 30), False), + (BQuarterEnd(1, month=2), datetime(2008, 5, 30), True), + (BQuarterEnd(1, month=2), datetime(2007, 6, 29), False), + (BQuarterEnd(1, month=2), datetime(2007, 6, 30), False), + (BQuarterEnd(1, month=3), datetime(2008, 1, 31), False), + (BQuarterEnd(1, month=3), datetime(2007, 12, 31), True), + (BQuarterEnd(1, month=3), datetime(2008, 2, 29), False), + (BQuarterEnd(1, month=3), datetime(2007, 3, 30), True), + (BQuarterEnd(1, month=3), datetime(2007, 3, 31), False), + (BQuarterEnd(1, month=3), datetime(2008, 4, 30), False), + (BQuarterEnd(1, month=3), datetime(2008, 5, 30), False), + (BQuarterEnd(1, month=3), datetime(2007, 6, 29), True), + (BQuarterEnd(1, month=3), datetime(2007, 6, 30), False), ] @pytest.mark.parametrize("case", on_offset_cases) diff --git a/pandas/tests/tslibs/test_libfrequencies.py b/pandas/tests/tslibs/test_libfrequencies.py index 83f28f6b5dc01..0640d4da78772 100644 --- a/pandas/tests/tslibs/test_libfrequencies.py +++ b/pandas/tests/tslibs/test_libfrequencies.py @@ -13,9 +13,9 @@ ("D", "DEC"), (offsets.Day().freqstr, "DEC"), ("Q", "DEC"), - (offsets.QuarterEnd(startingMonth=12).freqstr, "DEC"), + (offsets.QuarterEnd(month=12).freqstr, "DEC"), ("Q-JAN", "JAN"), - (offsets.QuarterEnd(startingMonth=1).freqstr, "JAN"), + (offsets.QuarterEnd(month=1).freqstr, "JAN"), ("A-DEC", "DEC"), ("Y-DEC", "DEC"), (offsets.YearEnd().freqstr, "DEC"), diff --git a/pandas/tests/tslibs/test_to_offset.py b/pandas/tests/tslibs/test_to_offset.py index 27ddbb82f49a9..ec3b20a152f69 100644 --- a/pandas/tests/tslibs/test_to_offset.py +++ b/pandas/tests/tslibs/test_to_offset.py @@ -158,9 +158,9 @@ def test_to_offset_pd_timedelta(kwargs, expected): [ ("W", offsets.Week(weekday=6)), ("W-SUN", offsets.Week(weekday=6)), - ("Q", offsets.QuarterEnd(startingMonth=12)), - ("Q-DEC", offsets.QuarterEnd(startingMonth=12)), - ("Q-MAY", offsets.QuarterEnd(startingMonth=5)), + ("Q", offsets.QuarterEnd(month=12)), + ("Q-DEC", offsets.QuarterEnd(month=12)), + ("Q-MAY", offsets.QuarterEnd(month=5)), ("SM", offsets.SemiMonthEnd(day_of_month=15)), ("SM-15", offsets.SemiMonthEnd(day_of_month=15)), ("SM-1", offsets.SemiMonthEnd(day_of_month=1)),