Skip to content

Commit 1d56672

Browse files
authored
DEPR: rename BQ to BQE for offsets (#55978)
1 parent 41bb434 commit 1d56672

File tree

17 files changed

+87
-42
lines changed

17 files changed

+87
-42
lines changed

doc/source/user_guide/timeseries.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ into ``freq`` keyword arguments. The available date offsets and associated frequ
886886
:class:`~pandas.tseries.offsets.SemiMonthBegin`, ``'SMS'``, "15th (or other day_of_month) and calendar month begin"
887887
:class:`~pandas.tseries.offsets.QuarterEnd`, ``'QE'``, "calendar quarter end"
888888
:class:`~pandas.tseries.offsets.QuarterBegin`, ``'QS'``, "calendar quarter begin"
889-
:class:`~pandas.tseries.offsets.BQuarterEnd`, ``'BQ``, "business quarter end"
889+
:class:`~pandas.tseries.offsets.BQuarterEnd`, ``'BQE``, "business quarter end"
890890
:class:`~pandas.tseries.offsets.BQuarterBegin`, ``'BQS'``, "business quarter begin"
891891
:class:`~pandas.tseries.offsets.FY5253Quarter`, ``'REQ'``, "retail (aka 52-53 week) quarter"
892892
:class:`~pandas.tseries.offsets.YearEnd`, ``'YE'``, "calendar year end"
@@ -1249,7 +1249,7 @@ frequencies. We will refer to these aliases as *offset aliases*.
12491249
"BMS", "business month start frequency"
12501250
"CBMS", "custom business month start frequency"
12511251
"QE", "quarter end frequency"
1252-
"BQ", "business quarter end frequency"
1252+
"BQE", "business quarter end frequency"
12531253
"QS", "quarter start frequency"
12541254
"BQS", "business quarter start frequency"
12551255
"YE", "year end frequency"
@@ -1686,7 +1686,7 @@ the end of the interval.
16861686
.. warning::
16871687

16881688
The default values for ``label`` and ``closed`` is '**left**' for all
1689-
frequency offsets except for 'ME', 'YE', 'QE', 'BME', 'BY', 'BQ', and 'W'
1689+
frequency offsets except for 'ME', 'YE', 'QE', 'BME', 'BY', 'BQE', and 'W'
16901690
which all have a default of 'right'.
16911691

16921692
This might unintendedly lead to looking ahead, where the value for a later

doc/source/whatsnew/v2.2.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ Other Deprecations
289289
- Deprecated string ``A`` denoting frequency in :class:`YearEnd` and strings ``A-DEC``, ``A-JAN``, etc. denoting annual frequencies with various fiscal year ends (:issue:`54275`)
290290
- Deprecated string ``BAS`` denoting frequency in :class:`BYearBegin` and strings ``BAS-DEC``, ``BAS-JAN``, etc. denoting annual frequencies with various fiscal year starts (:issue:`54275`)
291291
- Deprecated string ``BA`` denoting frequency in :class:`BYearEnd` and strings ``BA-DEC``, ``BA-JAN``, etc. denoting annual frequencies with various fiscal year ends (:issue:`54275`)
292+
- Deprecated string ``BQ`` denoting frequency in :class:`BQuarterEnd` (:issue:`52064`)
292293
- Deprecated strings ``BM``, and ``CBM`` denoting frequencies in :class:`BusinessMonthEnd`, :class:`CustomBusinessMonthEnd` (:issue:`52064`)
293294
- Deprecated strings ``H``, ``BH``, and ``CBH`` denoting frequencies in :class:`Hour`, :class:`BusinessHour`, :class:`CustomBusinessHour` (:issue:`52536`)
294295
- Deprecated strings ``H``, ``S``, ``U``, and ``N`` denoting units in :func:`to_timedelta` (:issue:`52536`)

pandas/_libs/tslibs/dtypes.pyx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,19 @@ OFFSET_TO_PERIOD_FREQSTR: dict = {
177177
"BME": "M",
178178
"BQS": "Q",
179179
"QS": "Q",
180-
"BQ": "Q",
180+
"BQE": "Q",
181+
"BQE-DEC": "Q-DEC",
182+
"BQE-JAN": "Q-JAN",
183+
"BQE-FEB": "Q-FEB",
184+
"BQE-MAR": "Q-MAR",
185+
"BQE-APR": "Q-APR",
186+
"BQE-MAY": "Q-MAY",
187+
"BQE-JUN": "Q-JUN",
188+
"BQE-JUL": "Q-JUL",
189+
"BQE-AUG": "Q-AUG",
190+
"BQE-SEP": "Q-SEP",
191+
"BQE-OCT": "Q-OCT",
192+
"BQE-NOV": "Q-NOV",
181193
"MS": "M",
182194
"D": "D",
183195
"B": "B",
@@ -261,6 +273,21 @@ cdef dict c_OFFSET_DEPR_FREQSTR = {
261273
"A-SEP": "YE-SEP",
262274
"A-OCT": "YE-OCT",
263275
"A-NOV": "YE-NOV",
276+
"BM": "BME",
277+
"CBM": "CBME",
278+
"BQ": "BQE",
279+
"BQ-DEC": "BQE-DEC",
280+
"BQ-JAN": "BQE-JAN",
281+
"BQ-FEB": "BQE-FEB",
282+
"BQ-MAR": "BQE-MAR",
283+
"BQ-APR": "BQE-APR",
284+
"BQ-MAY": "BQE-MAY",
285+
"BQ-JUN": "BQE-JUN",
286+
"BQ-JUL": "BQE-JUL",
287+
"BQ-AUG": "BQE-AUG",
288+
"BQ-SEP": "BQE-SEP",
289+
"BQ-OCT": "BQE-OCT",
290+
"BQ-NOV": "BQE-NOV",
264291
}
265292
cdef dict c_OFFSET_TO_PERIOD_FREQSTR = OFFSET_TO_PERIOD_FREQSTR
266293
cdef dict c_REVERSE_OFFSET_DEPR_FREQSTR = {

pandas/_libs/tslibs/offsets.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2670,7 +2670,7 @@ cdef class BQuarterEnd(QuarterOffset):
26702670
_output_name = "BusinessQuarterEnd"
26712671
_default_starting_month = 3
26722672
_from_name_starting_month = 12
2673-
_prefix = "BQ"
2673+
_prefix = "BQE"
26742674
_day_opt = "business_end"
26752675

26762676

@@ -4545,7 +4545,7 @@ prefix_mapping = {
45454545
BusinessDay, # 'B'
45464546
BusinessMonthBegin, # 'BMS'
45474547
BusinessMonthEnd, # 'BME'
4548-
BQuarterEnd, # 'BQ'
4548+
BQuarterEnd, # 'BQE'
45494549
BQuarterBegin, # 'BQS'
45504550
BusinessHour, # 'bh'
45514551
CustomBusinessDay, # 'C'
@@ -4729,7 +4729,7 @@ cpdef to_offset(freq, bint is_period=False):
47294729
for n, (sep, stride, name) in enumerate(tups):
47304730
if is_period is False and name in c_OFFSET_DEPR_FREQSTR:
47314731
warnings.warn(
4732-
f"\'{name}\' will be deprecated, please use "
4732+
f"\'{name}\' is deprecated, please use "
47334733
f"\'{c_OFFSET_DEPR_FREQSTR.get(name)}\' instead.",
47344734
FutureWarning,
47354735
stacklevel=find_stack_level(),

pandas/core/generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9200,11 +9200,11 @@ def resample(
92009200
closed : {{'right', 'left'}}, default None
92019201
Which side of bin interval is closed. The default is 'left'
92029202
for all frequency offsets except for 'ME', 'YE', 'QE', 'BME',
9203-
'BA', 'BQ', and 'W' which all have a default of 'right'.
9203+
'BA', 'BQE', and 'W' which all have a default of 'right'.
92049204
label : {{'right', 'left'}}, default None
92059205
Which bin edge label to label bucket with. The default is 'left'
92069206
for all frequency offsets except for 'ME', 'YE', 'QE', 'BME',
9207-
'BA', 'BQ', and 'W' which all have a default of 'right'.
9207+
'BA', 'BQE', and 'W' which all have a default of 'right'.
92089208
convention : {{'start', 'end', 's', 'e'}}, default 'start'
92099209
For `PeriodIndex` only, controls whether to use the start or
92109210
end of `rule`.

pandas/core/resample.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,7 +2130,7 @@ def __init__(
21302130
else:
21312131
freq = to_offset(freq)
21322132

2133-
end_types = {"ME", "YE", "QE", "BME", "BY", "BQ", "W"}
2133+
end_types = {"ME", "YE", "QE", "BME", "BY", "BQE", "W"}
21342134
rule = freq.rule_code
21352135
if rule in end_types or ("-" in rule and rule[: rule.find("-")] in end_types):
21362136
if closed is None:
@@ -2327,7 +2327,7 @@ def _adjust_bin_edges(
23272327
# Some hacks for > daily data, see #1471, #1458, #1483
23282328

23292329
if self.freq.name in ("BME", "ME", "W") or self.freq.name.split("-")[0] in (
2330-
"BQ",
2330+
"BQE",
23312331
"BY",
23322332
"QE",
23332333
"YE",

pandas/tests/arrays/test_datetimes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,7 @@ def test_iter_zoneinfo_fold(self, tz):
772772
)
773773
def test_date_range_frequency_M_Q_Y_A_deprecated(self, freq, freq_depr):
774774
# GH#9586, GH#54275
775-
depr_msg = (
776-
f"'{freq_depr[1:]}' will be deprecated, please use '{freq[1:]}' instead."
777-
)
775+
depr_msg = f"'{freq_depr[1:]}' is deprecated, please use '{freq[1:]}' instead."
778776

779777
expected = pd.date_range("1/1/2000", periods=4, freq=freq)
780778
with tm.assert_produces_warning(FutureWarning, match=depr_msg):

pandas/tests/frame/methods/test_asfreq.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,17 @@ def test_asfreq_2ME(self, freq, freq_half):
240240
("2ME", "2M"),
241241
("2QE", "2Q"),
242242
("2QE-SEP", "2Q-SEP"),
243+
("1BQE", "1BQ"),
244+
("2BQE-SEP", "2BQ-SEP"),
243245
("1YE", "1Y"),
244246
("2YE-MAR", "2Y-MAR"),
245247
("1YE", "1A"),
246248
("2YE-MAR", "2A-MAR"),
247249
],
248250
)
249251
def test_asfreq_frequency_M_Q_Y_A_deprecated(self, freq, freq_depr):
250-
# GH#9586
251-
depr_msg = (
252-
f"'{freq_depr[1:]}' will be deprecated, please use '{freq[1:]}' instead."
253-
)
252+
# GH#9586, #55978
253+
depr_msg = f"'{freq_depr[1:]}' is deprecated, please use '{freq[1:]}' instead."
254254

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

pandas/tests/indexes/datetimes/methods/test_to_period.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_to_period_quarterly(self, month):
5050
result = stamps.to_period(freq)
5151
tm.assert_index_equal(rng, result)
5252

53-
@pytest.mark.parametrize("off", ["BQ", "QS", "BQS"])
53+
@pytest.mark.parametrize("off", ["BQE", "QS", "BQS"])
5454
def test_to_period_quarterlyish(self, off):
5555
rng = date_range("01-Jan-2012", periods=8, freq=off)
5656
prng = rng.to_period()
@@ -103,7 +103,7 @@ def test_dti_to_period_2monthish(self, freq_offset, freq_period):
103103
)
104104
def test_to_period_frequency_M_Q_Y_A_deprecated(self, freq, freq_depr):
105105
# GH#9586
106-
msg = f"'{freq_depr[1:]}' will be deprecated, please use '{freq[1:]}' instead."
106+
msg = f"'{freq_depr[1:]}' is deprecated, please use '{freq[1:]}' instead."
107107

108108
rng = date_range("01-Jan-2012", periods=8, freq=freq)
109109
prng = rng.to_period()

pandas/tests/indexes/datetimes/test_date_range.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def test_date_range_float_periods(self):
146146
tm.assert_index_equal(rng, exp)
147147

148148
def test_date_range_frequency_M_deprecated(self):
149-
depr_msg = "'M' will be deprecated, please use 'ME' instead."
149+
depr_msg = "'M' is deprecated, please use 'ME' instead."
150150

151151
expected = date_range("1/1/2000", periods=4, freq="2ME")
152152
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
@@ -797,7 +797,7 @@ def test_frequencies_A_deprecated_Y_renamed(self, freq, freq_depr):
797797
# GH#9586, GH#54275
798798
freq_msg = re.split("[0-9]*", freq, maxsplit=1)[1]
799799
freq_depr_msg = re.split("[0-9]*", freq_depr, maxsplit=1)[1]
800-
msg = f"'{freq_depr_msg}' will be deprecated, please use '{freq_msg}' instead."
800+
msg = f"'{freq_depr_msg}' is deprecated, please use '{freq_msg}' instead."
801801

802802
expected = date_range("1/1/2000", periods=2, freq=freq)
803803
with tm.assert_produces_warning(FutureWarning, match=msg):
@@ -1678,7 +1678,7 @@ def test_date_range_fy5253(self, unit):
16781678
"freqstr,offset",
16791679
[
16801680
("QS", offsets.QuarterBegin(startingMonth=1)),
1681-
("BQ", offsets.BQuarterEnd(startingMonth=12)),
1681+
("BQE", offsets.BQuarterEnd(startingMonth=12)),
16821682
("W-SUN", offsets.Week(weekday=6)),
16831683
],
16841684
)

0 commit comments

Comments
 (0)