Skip to content

Commit 59235de

Browse files
authored
CLN: remove deprecated strings 'BA', 'BAS', 'AS' denoting frequencies for timeseries (#57793)
* remove BA, BAS-from timeseries freq, fix tests * remove AS from timeseries freq, add test * add notes to v3.0.0 * correct def to_offset
1 parent fd1126c commit 59235de

File tree

4 files changed

+22
-92
lines changed

4 files changed

+22
-92
lines changed

doc/source/whatsnew/v3.0.0.rst

+3
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ Removal of prior version deprecations/changes
203203
- Enforced deprecation of :meth:`.DataFrameGroupBy.get_group` and :meth:`.SeriesGroupBy.get_group` allowing the ``name`` argument to be a non-tuple when grouping by a list of length 1 (:issue:`54155`)
204204
- Enforced deprecation of ``axis=None`` acting the same as ``axis=0`` in the DataFrame reductions ``sum``, ``prod``, ``std``, ``var``, and ``sem``, passing ``axis=None`` will now reduce over both axes; this is particularly the case when doing e.g. ``numpy.sum(df)`` (:issue:`21597`)
205205
- Enforced deprecation of passing a dictionary to :meth:`SeriesGroupBy.agg` (:issue:`52268`)
206+
- Enforced deprecation of string ``AS`` denoting frequency in :class:`YearBegin` and strings ``AS-DEC``, ``AS-JAN``, etc. denoting annual frequencies with various fiscal year starts (:issue:`57793`)
206207
- Enforced deprecation of string ``A`` denoting frequency in :class:`YearEnd` and strings ``A-DEC``, ``A-JAN``, etc. denoting annual frequencies with various fiscal year ends (:issue:`57699`)
208+
- Enforced deprecation of string ``BAS`` denoting frequency in :class:`BYearBegin` and strings ``BAS-DEC``, ``BAS-JAN``, etc. denoting annual frequencies with various fiscal year starts (:issue:`57793`)
209+
- Enforced deprecation of string ``BA`` denoting frequency in :class:`BYearEnd` and strings ``BA-DEC``, ``BA-JAN``, etc. denoting annual frequencies with various fiscal year ends (:issue:`57793`)
207210
- Enforced deprecation of the behavior of :func:`concat` when ``len(keys) != len(objs)`` would truncate to the shorter of the two. Now this raises a ``ValueError`` (:issue:`43485`)
208211
- Enforced silent-downcasting deprecation for :ref:`all relevant methods <whatsnew_220.silent_downcasting>` (:issue:`54710`)
209212
- In :meth:`DataFrame.stack`, the default value of ``future_stack`` is now ``True``; specifying ``False`` will raise a ``FutureWarning`` (:issue:`55448`)

pandas/_libs/tslibs/dtypes.pyx

-52
Original file line numberDiff line numberDiff line change
@@ -286,19 +286,6 @@ cdef dict c_OFFSET_DEPR_FREQSTR = {
286286
"BY-SEP": "BYE-SEP",
287287
"BY-OCT": "BYE-OCT",
288288
"BY-NOV": "BYE-NOV",
289-
"BA": "BYE",
290-
"BA-DEC": "BYE-DEC",
291-
"BA-JAN": "BYE-JAN",
292-
"BA-FEB": "BYE-FEB",
293-
"BA-MAR": "BYE-MAR",
294-
"BA-APR": "BYE-APR",
295-
"BA-MAY": "BYE-MAY",
296-
"BA-JUN": "BYE-JUN",
297-
"BA-JUL": "BYE-JUL",
298-
"BA-AUG": "BYE-AUG",
299-
"BA-SEP": "BYE-SEP",
300-
"BA-OCT": "BYE-OCT",
301-
"BA-NOV": "BYE-NOV",
302289
"BM": "BME",
303290
"CBM": "CBME",
304291
"SM": "SME",
@@ -323,45 +310,6 @@ cdef dict c_REVERSE_OFFSET_DEPR_FREQSTR = {
323310

324311
# Map deprecated resolution abbreviations to correct resolution abbreviations
325312
cdef dict c_DEPR_ABBREVS = {
326-
"BA": "BY",
327-
"BA-DEC": "BY-DEC",
328-
"BA-JAN": "BY-JAN",
329-
"BA-FEB": "BY-FEB",
330-
"BA-MAR": "BY-MAR",
331-
"BA-APR": "BY-APR",
332-
"BA-MAY": "BY-MAY",
333-
"BA-JUN": "BY-JUN",
334-
"BA-JUL": "BY-JUL",
335-
"BA-AUG": "BY-AUG",
336-
"BA-SEP": "BY-SEP",
337-
"BA-OCT": "BY-OCT",
338-
"BA-NOV": "BY-NOV",
339-
"AS": "YS",
340-
"AS-DEC": "YS-DEC",
341-
"AS-JAN": "YS-JAN",
342-
"AS-FEB": "YS-FEB",
343-
"AS-MAR": "YS-MAR",
344-
"AS-APR": "YS-APR",
345-
"AS-MAY": "YS-MAY",
346-
"AS-JUN": "YS-JUN",
347-
"AS-JUL": "YS-JUL",
348-
"AS-AUG": "YS-AUG",
349-
"AS-SEP": "YS-SEP",
350-
"AS-OCT": "YS-OCT",
351-
"AS-NOV": "YS-NOV",
352-
"BAS": "BYS",
353-
"BAS-DEC": "BYS-DEC",
354-
"BAS-JAN": "BYS-JAN",
355-
"BAS-FEB": "BYS-FEB",
356-
"BAS-MAR": "BYS-MAR",
357-
"BAS-APR": "BYS-APR",
358-
"BAS-MAY": "BYS-MAY",
359-
"BAS-JUN": "BYS-JUN",
360-
"BAS-JUL": "BYS-JUL",
361-
"BAS-AUG": "BYS-AUG",
362-
"BAS-SEP": "BYS-SEP",
363-
"BAS-OCT": "BYS-OCT",
364-
"BAS-NOV": "BYS-NOV",
365313
"H": "h",
366314
"BH": "bh",
367315
"CBH": "cbh",

pandas/tests/frame/methods/test_asfreq.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,9 @@ def test_asfreq_2ME(self, freq, freq_half):
242242
("2BQE-SEP", "2BQ-SEP"),
243243
("1YE", "1Y"),
244244
("2YE-MAR", "2Y-MAR"),
245-
("2BYE-MAR", "2BA-MAR"),
246245
],
247246
)
248-
def test_asfreq_frequency_M_Q_Y_A_deprecated(self, freq, freq_depr):
247+
def test_asfreq_frequency_M_Q_Y_deprecated(self, freq, freq_depr):
249248
# GH#9586, #55978
250249
depr_msg = f"'{freq_depr[1:]}' is deprecated and will be removed "
251250
f"in a future version, please use '{freq[1:]}' instead."
@@ -282,11 +281,18 @@ def test_asfreq_unsupported_freq(self, freq, error_msg):
282281
with pytest.raises(ValueError, match=error_msg):
283282
df.asfreq(freq=freq)
284283

285-
def test_asfreq_frequency_A_raises(self):
286-
msg = "Invalid frequency: 2A"
284+
@pytest.mark.parametrize(
285+
"freq, freq_depr",
286+
[
287+
("2YE", "2A"),
288+
("2BYE-MAR", "2BA-MAR"),
289+
],
290+
)
291+
def test_asfreq_frequency_A_BA_raises(self, freq, freq_depr):
292+
msg = f"Invalid frequency: {freq_depr}"
287293

288-
index = date_range("1/1/2000", periods=4, freq="2ME")
294+
index = date_range("1/1/2000", periods=4, freq=freq)
289295
df = DataFrame({"s": Series([0.0, 1.0, 2.0, 3.0], index=index)})
290296

291297
with pytest.raises(ValueError, match=msg):
292-
df.asfreq(freq="2A")
298+
df.asfreq(freq=freq_depr)

pandas/tests/indexes/datetimes/test_datetime.py

+7-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import datetime as dt
22
from datetime import date
3-
import re
43

54
import numpy as np
65
import pytest
@@ -158,42 +157,9 @@ def test_CBH_deprecated(self):
158157

159158
tm.assert_index_equal(result, expected)
160159

161-
@pytest.mark.parametrize(
162-
"freq_depr, expected_values, expected_freq",
163-
[
164-
(
165-
"AS-AUG",
166-
["2021-08-01", "2022-08-01", "2023-08-01"],
167-
"YS-AUG",
168-
),
169-
(
170-
"1BAS-MAY",
171-
["2021-05-03", "2022-05-02", "2023-05-01"],
172-
"1BYS-MAY",
173-
),
174-
],
175-
)
176-
def test_AS_BAS_deprecated(self, freq_depr, expected_values, expected_freq):
177-
# GH#55479
178-
freq_msg = re.split("[0-9]*", freq_depr, maxsplit=1)[1]
179-
msg = f"'{freq_msg}' is deprecated and will be removed in a future version."
180-
181-
with tm.assert_produces_warning(FutureWarning, match=msg):
182-
expected = date_range(
183-
dt.datetime(2020, 12, 1), dt.datetime(2023, 12, 1), freq=freq_depr
184-
)
185-
result = DatetimeIndex(
186-
expected_values,
187-
dtype="datetime64[ns]",
188-
freq=expected_freq,
189-
)
190-
191-
tm.assert_index_equal(result, expected)
192-
193160
@pytest.mark.parametrize(
194161
"freq, expected_values, freq_depr",
195162
[
196-
("2BYE-MAR", ["2016-03-31"], "2BA-MAR"),
197163
("2BYE-JUN", ["2016-06-30"], "2BY-JUN"),
198164
("2BME", ["2016-02-29", "2016-04-29", "2016-06-30"], "2BM"),
199165
("2BQE", ["2016-03-31"], "2BQ"),
@@ -214,3 +180,10 @@ def test_BM_BQ_BY_deprecated(self, freq, expected_values, freq_depr):
214180
)
215181

216182
tm.assert_index_equal(result, expected)
183+
184+
@pytest.mark.parametrize("freq", ["2BA-MAR", "1BAS-MAY", "2AS-AUG"])
185+
def test_BA_BAS_raises(self, freq):
186+
msg = f"Invalid frequency: {freq}"
187+
188+
with pytest.raises(ValueError, match=msg):
189+
date_range(start="2016-02-21", end="2016-08-21", freq=freq)

0 commit comments

Comments
 (0)