-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
ENH: Use 'Y' as an alias for end of year #16978
Changes from all commits
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 |
---|---|---|
|
@@ -248,9 +248,10 @@ def test_anchored_shortcuts(self): | |
|
||
# ensure invalid cases fail as expected | ||
invalid_anchors = ['SM-0', 'SM-28', 'SM-29', | ||
'SM-FOO', 'BSM', 'SM--1' | ||
'SM-FOO', 'BSM', 'SM--1', | ||
'SMS-1', 'SMS-28', 'SMS-30', | ||
'SMS-BAR', 'BSMS', 'SMS--2'] | ||
'SMS-BAR', 'SMS-BYR' 'BSMS', | ||
'SMS--2'] | ||
for invalid_anchor in invalid_anchors: | ||
with tm.assert_raises_regex(ValueError, | ||
'Invalid frequency: '): | ||
|
@@ -292,11 +293,15 @@ def test_get_rule_month(): | |
|
||
result = frequencies._get_rule_month('A-DEC') | ||
assert (result == 'DEC') | ||
result = frequencies._get_rule_month('Y-DEC') | ||
assert (result == 'DEC') | ||
result = frequencies._get_rule_month(offsets.YearEnd()) | ||
assert (result == 'DEC') | ||
|
||
result = frequencies._get_rule_month('A-MAY') | ||
assert (result == 'MAY') | ||
result = frequencies._get_rule_month('Y-MAY') | ||
assert (result == 'MAY') | ||
result = frequencies._get_rule_month(offsets.YearEnd(month=5)) | ||
assert (result == 'MAY') | ||
|
||
|
@@ -305,6 +310,10 @@ def test_period_str_to_code(): | |
assert (frequencies._period_str_to_code('A') == 1000) | ||
assert (frequencies._period_str_to_code('A-DEC') == 1000) | ||
assert (frequencies._period_str_to_code('A-JAN') == 1001) | ||
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. tests for YS as well (like AS) 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. Umm...where do we actually test 'AS' in this file? 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 added tests for "AS" in |
||
assert (frequencies._period_str_to_code('Y') == 1000) | ||
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 would add tests that validate things with 'A', 'YS', 'AS' as well here, similar to Y 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. Not sure what you mean here: neither 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. well, where is AS tested then? 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. In |
||
assert (frequencies._period_str_to_code('Y-DEC') == 1000) | ||
assert (frequencies._period_str_to_code('Y-JAN') == 1001) | ||
|
||
assert (frequencies._period_str_to_code('Q') == 2000) | ||
assert (frequencies._period_str_to_code('Q-DEC') == 2000) | ||
assert (frequencies._period_str_to_code('Q-FEB') == 2002) | ||
|
@@ -349,6 +358,10 @@ def test_freq_code(self): | |
assert frequencies.get_freq('3A') == 1000 | ||
assert frequencies.get_freq('-1A') == 1000 | ||
|
||
assert frequencies.get_freq('Y') == 1000 | ||
assert frequencies.get_freq('3Y') == 1000 | ||
assert frequencies.get_freq('-1Y') == 1000 | ||
|
||
assert frequencies.get_freq('W') == 4000 | ||
assert frequencies.get_freq('W-MON') == 4001 | ||
assert frequencies.get_freq('W-FRI') == 4005 | ||
|
@@ -369,6 +382,13 @@ def test_freq_group(self): | |
assert frequencies.get_freq_group('-1A') == 1000 | ||
assert frequencies.get_freq_group('A-JAN') == 1000 | ||
assert frequencies.get_freq_group('A-MAY') == 1000 | ||
|
||
assert frequencies.get_freq_group('Y') == 1000 | ||
assert frequencies.get_freq_group('3Y') == 1000 | ||
assert frequencies.get_freq_group('-1Y') == 1000 | ||
assert frequencies.get_freq_group('Y-JAN') == 1000 | ||
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. also BYS (assume BAS is validated somewhere) 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. Not sure what you mean here: neither |
||
assert frequencies.get_freq_group('Y-MAY') == 1000 | ||
|
||
assert frequencies.get_freq_group(offsets.YearEnd()) == 1000 | ||
assert frequencies.get_freq_group(offsets.YearEnd(month=1)) == 1000 | ||
assert frequencies.get_freq_group(offsets.YearEnd(month=5)) == 1000 | ||
|
@@ -790,12 +810,6 @@ def test_series(self): | |
for freq in [None, 'L']: | ||
s = Series(period_range('2013', periods=10, freq=freq)) | ||
pytest.raises(TypeError, lambda: frequencies.infer_freq(s)) | ||
for freq in ['Y']: | ||
|
||
msg = frequencies._INVALID_FREQ_ERROR | ||
with tm.assert_raises_regex(ValueError, msg): | ||
s = Series(period_range('2013', periods=10, freq=freq)) | ||
pytest.raises(TypeError, lambda: frequencies.infer_freq(s)) | ||
|
||
# DateTimeIndex | ||
for freq in ['M', 'L', 'S']: | ||
|
@@ -812,11 +826,12 @@ def test_legacy_offset_warnings(self): | |
'W@FRI', 'W@SAT', 'W@SUN', 'Q@JAN', 'Q@FEB', 'Q@MAR', | ||
'A@JAN', 'A@FEB', 'A@MAR', 'A@APR', 'A@MAY', 'A@JUN', | ||
'A@JUL', 'A@AUG', 'A@SEP', 'A@OCT', 'A@NOV', 'A@DEC', | ||
'WOM@1MON', 'WOM@2MON', 'WOM@3MON', 'WOM@4MON', | ||
'WOM@1TUE', 'WOM@2TUE', 'WOM@3TUE', 'WOM@4TUE', | ||
'WOM@1WED', 'WOM@2WED', 'WOM@3WED', 'WOM@4WED', | ||
'WOM@1THU', 'WOM@2THU', 'WOM@3THU', 'WOM@4THU' | ||
'WOM@1FRI', 'WOM@2FRI', 'WOM@3FRI', 'WOM@4FRI'] | ||
'Y@JAN', 'WOM@1MON', 'WOM@2MON', 'WOM@3MON', | ||
'WOM@4MON', 'WOM@1TUE', 'WOM@2TUE', 'WOM@3TUE', | ||
'WOM@4TUE', 'WOM@1WED', 'WOM@2WED', 'WOM@3WED', | ||
'WOM@4WED', 'WOM@1THU', 'WOM@2THU', 'WOM@3THU', | ||
'WOM@4THU', 'WOM@1FRI', 'WOM@2FRI', 'WOM@3FRI', | ||
'WOM@4FRI'] | ||
|
||
msg = frequencies._INVALID_FREQ_ERROR | ||
for freq in freqs: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to the class for Business tests (below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is for
date_range
, notbdate_range
though. There are a bunch of business tests related to business anddate_range
already in this class (and not the Business one).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm ok.