Skip to content
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

CLN: remove deprecated strings 'BA', 'BAS', 'AS' denoting frequencies for timeseries #57793

Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ Removal of prior version deprecations/changes
- 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`)
- 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`)
- Enforced deprecation of passing a dictionary to :meth:`SeriesGroupBy.agg` (:issue:`52268`)
- 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`)
- 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`)
- 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`)
- 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`)
- 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`)
- Enforced silent-downcasting deprecation for :ref:`all relevant methods <whatsnew_220.silent_downcasting>` (:issue:`54710`)
- In :meth:`DataFrame.stack`, the default value of ``future_stack`` is now ``True``; specifying ``False`` will raise a ``FutureWarning`` (:issue:`55448`)
Expand Down
52 changes: 0 additions & 52 deletions pandas/_libs/tslibs/dtypes.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -286,19 +286,6 @@ cdef dict c_OFFSET_DEPR_FREQSTR = {
"BY-SEP": "BYE-SEP",
"BY-OCT": "BYE-OCT",
"BY-NOV": "BYE-NOV",
"BA": "BYE",
"BA-DEC": "BYE-DEC",
"BA-JAN": "BYE-JAN",
"BA-FEB": "BYE-FEB",
"BA-MAR": "BYE-MAR",
"BA-APR": "BYE-APR",
"BA-MAY": "BYE-MAY",
"BA-JUN": "BYE-JUN",
"BA-JUL": "BYE-JUL",
"BA-AUG": "BYE-AUG",
"BA-SEP": "BYE-SEP",
"BA-OCT": "BYE-OCT",
"BA-NOV": "BYE-NOV",
"BM": "BME",
"CBM": "CBME",
"SM": "SME",
Expand All @@ -323,45 +310,6 @@ cdef dict c_REVERSE_OFFSET_DEPR_FREQSTR = {

# Map deprecated resolution abbreviations to correct resolution abbreviations
cdef dict c_DEPR_ABBREVS = {
"BA": "BY",
"BA-DEC": "BY-DEC",
"BA-JAN": "BY-JAN",
"BA-FEB": "BY-FEB",
"BA-MAR": "BY-MAR",
"BA-APR": "BY-APR",
"BA-MAY": "BY-MAY",
"BA-JUN": "BY-JUN",
"BA-JUL": "BY-JUL",
"BA-AUG": "BY-AUG",
"BA-SEP": "BY-SEP",
"BA-OCT": "BY-OCT",
"BA-NOV": "BY-NOV",
"AS": "YS",
"AS-DEC": "YS-DEC",
"AS-JAN": "YS-JAN",
"AS-FEB": "YS-FEB",
"AS-MAR": "YS-MAR",
"AS-APR": "YS-APR",
"AS-MAY": "YS-MAY",
"AS-JUN": "YS-JUN",
"AS-JUL": "YS-JUL",
"AS-AUG": "YS-AUG",
"AS-SEP": "YS-SEP",
"AS-OCT": "YS-OCT",
"AS-NOV": "YS-NOV",
"BAS": "BYS",
"BAS-DEC": "BYS-DEC",
"BAS-JAN": "BYS-JAN",
"BAS-FEB": "BYS-FEB",
"BAS-MAR": "BYS-MAR",
"BAS-APR": "BYS-APR",
"BAS-MAY": "BYS-MAY",
"BAS-JUN": "BYS-JUN",
"BAS-JUL": "BYS-JUL",
"BAS-AUG": "BYS-AUG",
"BAS-SEP": "BYS-SEP",
"BAS-OCT": "BYS-OCT",
"BAS-NOV": "BYS-NOV",
"H": "h",
"BH": "bh",
"CBH": "cbh",
Expand Down
18 changes: 12 additions & 6 deletions pandas/tests/frame/methods/test_asfreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,9 @@ def test_asfreq_2ME(self, freq, freq_half):
("2BQE-SEP", "2BQ-SEP"),
("1YE", "1Y"),
("2YE-MAR", "2Y-MAR"),
("2BYE-MAR", "2BA-MAR"),
],
)
def test_asfreq_frequency_M_Q_Y_A_deprecated(self, freq, freq_depr):
def test_asfreq_frequency_M_Q_Y_deprecated(self, freq, freq_depr):
# GH#9586, #55978
depr_msg = f"'{freq_depr[1:]}' is deprecated and will be removed "
f"in a future version, please use '{freq[1:]}' instead."
Expand Down Expand Up @@ -282,11 +281,18 @@ def test_asfreq_unsupported_freq(self, freq, error_msg):
with pytest.raises(ValueError, match=error_msg):
df.asfreq(freq=freq)

def test_asfreq_frequency_A_raises(self):
msg = "Invalid frequency: 2A"
@pytest.mark.parametrize(
"freq, freq_depr",
[
("2YE", "2A"),
("2BYE-MAR", "2BA-MAR"),
],
)
def test_asfreq_frequency_A_BA_raises(self, freq, freq_depr):
msg = f"Invalid frequency: {freq_depr}"

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

with pytest.raises(ValueError, match=msg):
df.asfreq(freq="2A")
df.asfreq(freq=freq_depr)
41 changes: 7 additions & 34 deletions pandas/tests/indexes/datetimes/test_datetime.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime as dt
from datetime import date
import re

import numpy as np
import pytest
Expand Down Expand Up @@ -158,42 +157,9 @@ def test_CBH_deprecated(self):

tm.assert_index_equal(result, expected)

@pytest.mark.parametrize(
"freq_depr, expected_values, expected_freq",
[
(
"AS-AUG",
["2021-08-01", "2022-08-01", "2023-08-01"],
"YS-AUG",
),
(
"1BAS-MAY",
["2021-05-03", "2022-05-02", "2023-05-01"],
"1BYS-MAY",
),
],
)
def test_AS_BAS_deprecated(self, freq_depr, expected_values, expected_freq):
# GH#55479
freq_msg = re.split("[0-9]*", freq_depr, maxsplit=1)[1]
msg = f"'{freq_msg}' is deprecated and will be removed in a future version."

with tm.assert_produces_warning(FutureWarning, match=msg):
expected = date_range(
dt.datetime(2020, 12, 1), dt.datetime(2023, 12, 1), freq=freq_depr
)
result = DatetimeIndex(
expected_values,
dtype="datetime64[ns]",
freq=expected_freq,
)

tm.assert_index_equal(result, expected)

@pytest.mark.parametrize(
"freq, expected_values, freq_depr",
[
("2BYE-MAR", ["2016-03-31"], "2BA-MAR"),
("2BYE-JUN", ["2016-06-30"], "2BY-JUN"),
("2BME", ["2016-02-29", "2016-04-29", "2016-06-30"], "2BM"),
("2BQE", ["2016-03-31"], "2BQ"),
Expand All @@ -214,3 +180,10 @@ def test_BM_BQ_BY_deprecated(self, freq, expected_values, freq_depr):
)

tm.assert_index_equal(result, expected)

@pytest.mark.parametrize("freq", ["2BA-MAR", "1BAS-MAY", "2AS-AUG"])
def test_BA_BAS_raises(self, freq):
msg = f"Invalid frequency: {freq}"

with pytest.raises(ValueError, match=msg):
date_range(start="2016-02-21", end="2016-08-21", freq=freq)
Loading