Get_period_alias(offset_str)
function behaves inconsistent
import pandas as pd
print(pd.tseries.frequencies.get_period_alias('AS-JAN')) # works fine
print(pd.tseries.frequencies.get_period_alias('AS-FEB')) # works fine
# ...
print(pd.tseries.frequencies.get_period_alias('W-MON')) # offset not removed
print(pd.tseries.frequencies.get_period_alias('W-TUE')) # offset not removed
# ...
print(pd.tseries.frequencies.get_period_alias('A-JAN')) # offset not removed
print(pd.tseries.frequencies.get_period_alias('A-FEB')) # offset not removed
# ...
Problem description
The Get_period_alias(offset_str)
behaves inconsistent for different frequencies. See code sample for examples. The offset information (JAN, FEB, MON, TUE, ... ) should be removed. The issue should be easy to resolve by modifying the following lines:
https://github.com/pandas-dev/pandas/blob/1f6710035a5295b2d3171ab811ae7ffca2344389/pandas/tseries/frequencies.py#L81-L87
Output:
A
A
W-MON
W-TUE
A-JAN
A-FEB
Expected Output
A
A
W
W
A
A
Output of pd.show_versions()
Comment From: jbrockmendel
Why? What user-facing behavior would this change/fix?
Comment From: stephprobst
Isn't pd.tseries.frequencies.get_period_alias
itself user-facing? If not, shouldn't it be prefixed with an underscore?
I'm personally using the function to extract the period information after using pd.infer_freq
.
Comment From: jbrockmendel
Good question. I don't usually think of things buried this deep as being public, but to_offset
is in that file and is pretty public.