-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DEPR: 'A' for yearly frequency and YearEnd in favour of 'Y' #55252
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
Changes from 13 commits
f87ddbe
7b0b956
ec6d3d9
606ebba
1f10870
0dea433
4498d87
dbd1da3
935280e
fd36bc7
9268a9b
9a383cd
ab0d6a6
4f91f7f
31e0bf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ from cpython.datetime cimport ( | |
time as dt_time, | ||
timedelta, | ||
) | ||
|
||
import warnings | ||
|
||
import_datetime() | ||
|
@@ -48,7 +49,6 @@ from pandas._libs.tslibs.ccalendar import ( | |
) | ||
from pandas.util._exceptions import find_stack_level | ||
|
||
|
||
from pandas._libs.tslibs.ccalendar cimport ( | ||
dayofweek, | ||
get_days_in_month, | ||
|
@@ -58,6 +58,8 @@ from pandas._libs.tslibs.ccalendar cimport ( | |
from pandas._libs.tslibs.conversion cimport localize_pydatetime | ||
from pandas._libs.tslibs.dtypes cimport ( | ||
c_DEPR_ABBREVS, | ||
c_OFFSET_DEPR_FREQSTR, | ||
c_REVERSE_OFFSET_DEPR_FREQSTR, | ||
periods_per_day, | ||
) | ||
from pandas._libs.tslibs.nattype cimport ( | ||
|
@@ -2496,7 +2498,7 @@ cdef class YearEnd(YearOffset): | |
""" | ||
|
||
_default_month = 12 | ||
_prefix = "A" | ||
_prefix = "Y" | ||
_day_opt = "end" | ||
|
||
cdef readonly: | ||
|
@@ -4447,7 +4449,7 @@ prefix_mapping = { | |
offset._prefix: offset | ||
for offset in [ | ||
YearBegin, # 'AS' | ||
YearEnd, # 'A' | ||
YearEnd, # 'Y' | ||
BYearBegin, # 'BAS' | ||
BYearEnd, # 'BA' | ||
BusinessDay, # 'B' | ||
|
@@ -4489,8 +4491,7 @@ _lite_rule_alias = { | |
"W": "W-SUN", | ||
"Q": "Q-DEC", | ||
|
||
"A": "A-DEC", # YearEnd(month=12), | ||
"Y": "A-DEC", | ||
"Y": "Y-DEC", # YearEnd(month=12), | ||
"AS": "AS-JAN", # YearBegin(month=1), | ||
"YS": "AS-JAN", | ||
"BA": "BA-DEC", # BYearEnd(month=12), | ||
|
@@ -4615,21 +4616,22 @@ cpdef to_offset(freq, bint is_period=False): | |
|
||
tups = zip(split[0::4], split[1::4], split[2::4]) | ||
for n, (sep, stride, name) in enumerate(tups): | ||
if is_period is False and name == "M": | ||
if is_period is False and name in c_OFFSET_DEPR_FREQSTR: | ||
warnings.warn( | ||
"\'M\' will be deprecated, please use \'ME\' " | ||
"for \'month end\'", | ||
f"\'{name}\' will be deprecated, please use " | ||
f"\'{c_OFFSET_DEPR_FREQSTR.get(name)}\' for Offsets.", | ||
MarcoGorelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
UserWarning, | ||
stacklevel=find_stack_level(), | ||
) | ||
name = "ME" | ||
if is_period is True and name == "ME": | ||
name = c_OFFSET_DEPR_FREQSTR[name] | ||
if is_period is True and name in c_REVERSE_OFFSET_DEPR_FREQSTR: | ||
raise ValueError( | ||
r"for Period, please use \'M\' " | ||
"instead of \'ME\'" | ||
f"for Period, please use " | ||
f"\'{c_REVERSE_OFFSET_DEPR_FREQSTR.get(name)}\' " | ||
f"instead of \'{name}\'" | ||
) | ||
elif is_period is True and name == "M": | ||
name = "ME" | ||
elif is_period is True and name in c_OFFSET_DEPR_FREQSTR: | ||
name = c_OFFSET_DEPR_FREQSTR.get(name) | ||
|
||
if sep != "" and not sep.isspace(): | ||
raise ValueError("separator must be spaces") | ||
|
@@ -4639,15 +4641,6 @@ cpdef to_offset(freq, bint is_period=False): | |
if not stride: | ||
stride = 1 | ||
|
||
if prefix in c_DEPR_ABBREVS: | ||
warnings.warn( | ||
f"\'{prefix}\' is deprecated and will be removed in a " | ||
f"future version. Please use \'{c_DEPR_ABBREVS.get(prefix)}\' " | ||
f"instead of \'{prefix}\'.", | ||
FutureWarning, | ||
stacklevel=find_stack_level(), | ||
) | ||
prefix = c_DEPR_ABBREVS[prefix] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as in the other PR, it's not clear to me why this moved down - could you explain please? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because I wanted to keep this together with line 4668: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah that might be better - wouldn't we risk missing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, I agree, we might have problems if frequency is 'T', 'S', 'L', 'U', or 'N'. Maybe we should check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved the check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
this is music to my ears - well done! |
||
if prefix in {"D", "H", "min", "s", "ms", "us", "ns"}: | ||
# For these prefixes, we have something like "3H" or | ||
# "2.5T", so we can construct a Timedelta with the | ||
|
@@ -4660,8 +4653,19 @@ cpdef to_offset(freq, bint is_period=False): | |
# into the offset | ||
offset *= stride_sign | ||
else: | ||
if prefix in c_DEPR_ABBREVS: | ||
warnings.warn( | ||
f"\'{prefix}\' is deprecated and will be removed " | ||
f"in a future version. Please use " | ||
f"\'{c_DEPR_ABBREVS.get(prefix)}\' " | ||
f"instead of \'{prefix}\'.", | ||
FutureWarning, | ||
stacklevel=find_stack_level(), | ||
) | ||
prefix = c_DEPR_ABBREVS[prefix] | ||
|
||
stride = int(stride) | ||
offset = _get_offset(name) | ||
offset = _get_offset(prefix) | ||
offset = offset * int(np.fabs(stride) * stride_sign) | ||
|
||
if delta is None: | ||
|
Uh oh!
There was an error while loading. Please reload this page.