http://stackoverflow.com/questions/12979062/using-a-custom-offset-alias-in-pandas
I'm thinking:
@offset_alias class CustomOffset(DateOffset): ...
Comment From: ghost
moved from 1.0 (the 'never' release? :) to current milestone with the rest of the rolling issues.
Comment From: bcbernardo
This was marked as completed in 2012, but there is no mention to this in the documentation nor occurrences of the suggested syntax in the code base...
Was it actually implemented? If so, how does one create a custom frequency alias in modern days pandas (currently v1.5.3)?
Comment From: Deepnika
Yes, facing the same issue here. Is there a way to create an offset class and register it with pandas to use with pd.infer_freq()
after adding the inference rule? Here's what I thought:
from pandas.tseries.offsets import CustomBusinessDay
class DailyExcludingSunday(CustomBusinessDay):
"""
Represents a custom frequency that occurs every day including Saturdays
but excluding Sundays.
"""
def __init__(self, **kwargs):
super().__init__(weekmask='Mon Tue Wed Thu Fri Sat', holidays=[], **kwargs)
@property
def name(self):
return 'daily_excluding_sunday'
idx = pd.date_range(start='2023-02-01', end='2023-02-28', freq=DailyExcludingSunday())
pd.infer_freq(idx) # Should return 'daily_excluding_sunday'