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

DEPR: remove deprecated freqs/abbrevs 'A', 'A-DEC', 'A-JAN', etc. #57699

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions pandas/_libs/tslibs/dtypes.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ cdef dict c_DEPR_ABBREVS
cdef dict attrname_to_abbrevs
cdef dict npy_unit_to_attrname
cdef dict attrname_to_npy_unit
cdef set c_REMOVED_ABBREVS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to keep track of these over time. Should just be able to remove from c_DEPR_ABBREVS and call it a day I think


cdef enum c_FreqGroup:
# Mirrors FreqGroup in the .pyx file
Expand Down
35 changes: 21 additions & 14 deletions pandas/_libs/tslibs/dtypes.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -336,20 +336,6 @@ cdef dict c_REVERSE_OFFSET_DEPR_FREQSTR = {

# Map deprecated resolution abbreviations to correct resolution abbreviations
cdef dict c_DEPR_ABBREVS = {
"A": "Y",
"a": "Y",
"A-DEC": "Y-DEC",
"A-JAN": "Y-JAN",
"A-FEB": "Y-FEB",
"A-MAR": "Y-MAR",
"A-APR": "Y-APR",
"A-MAY": "Y-MAY",
"A-JUN": "Y-JUN",
"A-JUL": "Y-JUL",
"A-AUG": "Y-AUG",
"A-SEP": "Y-SEP",
"A-OCT": "Y-OCT",
"A-NOV": "Y-NOV",
"BA": "BY",
"BA-DEC": "BY-DEC",
"BA-JAN": "BY-JAN",
Expand Down Expand Up @@ -403,6 +389,23 @@ cdef dict c_DEPR_ABBREVS = {
"n": "ns",
}

cdef set c_REMOVED_ABBREVS = {
"A",
"a",
"A-DEC",
"A-JAN",
"A-FEB",
"A-MAR",
"A-APR",
"A-MAY",
"A-JUN",
"A-JUL",
"A-AUG",
"A-SEP",
"A-OCT",
"A-NOV",
}


class FreqGroup(Enum):
# Mirrors c_FreqGroup in the .pxd file
Expand Down Expand Up @@ -494,6 +497,10 @@ class Resolution(Enum):
"""
cdef:
str abbrev
if freq == "A":
raise ValueError(
"Frequency \'A\' is no longer supported."
)
try:
if freq in c_DEPR_ABBREVS:
abbrev = c_DEPR_ABBREVS[freq]
Expand Down
13 changes: 7 additions & 6 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ from pandas._libs.tslibs.conversion cimport localize_pydatetime
from pandas._libs.tslibs.dtypes cimport (
c_DEPR_ABBREVS,
c_OFFSET_DEPR_FREQSTR,
c_REMOVED_ABBREVS,
c_REVERSE_OFFSET_DEPR_FREQSTR,
periods_per_day,
)
Expand Down Expand Up @@ -4886,12 +4887,8 @@ cpdef to_offset(freq, bint is_period=False):
)
elif is_period and name.upper() in c_OFFSET_DEPR_FREQSTR:
if name.upper().startswith("A"):
warnings.warn(
f"\'{name}\' is deprecated and will be removed in a future "
f"version, please use "
f"\'{c_DEPR_ABBREVS.get(name.upper())}\' instead.",
FutureWarning,
stacklevel=find_stack_level(),
raise ValueError(
f"Frequency \'{name}\' is no longer supported."
)
if name.upper() != name:
warnings.warn(
Expand All @@ -4911,6 +4908,10 @@ cpdef to_offset(freq, bint is_period=False):
if not stride:
stride = 1

if prefix in c_REMOVED_ABBREVS:
raise ValueError(
f"Frequency \'{prefix}\' is no longer supported."
)
if prefix in c_DEPR_ABBREVS:
warnings.warn(
f"\'{prefix}\' is deprecated and will be removed "
Expand Down
Loading