Skip to content

Commit 6522436

Browse files
committed
Frequency: raise warnings when using ‘M’ frequency II
1 parent d21c195 commit 6522436

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Diff for: pandas/_libs/tslibs/offsets.pyx

+6-4
Original file line numberDiff line numberDiff line change
@@ -2567,7 +2567,7 @@ cdef class MonthEnd(MonthOffset):
25672567
Timestamp('2022-01-31 00:00:00')
25682568
"""
25692569
_period_dtype_code = PeriodDtypeCode.M
2570-
_prefix = "M"
2570+
_prefix = "ME"
25712571
_day_opt = "end"
25722572

25732573

@@ -4067,7 +4067,7 @@ prefix_mapping = {
40674067
CustomBusinessMonthEnd, # 'CBM'
40684068
CustomBusinessMonthBegin, # 'CBMS'
40694069
CustomBusinessHour, # 'CBH'
4070-
MonthEnd, # 'M'
4070+
MonthEnd, # 'ME'
40714071
MonthBegin, # 'MS'
40724072
Nano, # 'N'
40734073
SemiMonthEnd, # 'SM'
@@ -4221,11 +4221,13 @@ cpdef to_offset(freq):
42214221

42224222
tups = zip(split[0::4], split[1::4], split[2::4])
42234223
for n, (sep, stride, name) in enumerate(tups):
4224-
if name == 'M':
4224+
if name == "M":
42254225
warnings.warn(
4226-
f"'M' will be deprecated, please use 'ME' for 'month end'",
4226+
r"\'M\' will be deprecated, please use \'ME\' "
4227+
"for \'month end\'",
42274228
UserWarning,
42284229
)
4230+
name = "ME"
42294231
if sep != "" and not sep.isspace():
42304232
raise ValueError("separator must be spaces")
42314233
prefix = _lite_rule_alias.get(name) or name

Diff for: pandas/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ def rand_series_with_duplicate_datetimeindex() -> Series:
896896
params=[
897897
(Interval(left=0, right=5), IntervalDtype("int64", "right")),
898898
(Interval(left=0.1, right=0.5), IntervalDtype("float64", "right")),
899-
(Period("2012-01", freq="M"), "period[M]"),
899+
(Period("2012-01", freq="ME"), "period[ME]"),
900900
(Period("2012-02-01", freq="D"), "period[D]"),
901901
(
902902
Timestamp("2011-01-01", tz="US/Eastern"),

0 commit comments

Comments
 (0)