Skip to content

Week Start/End Resamping: WS/WE frequencies #15449

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions pandas/tseries/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ def _get_freq_str(base, mult=1):


from pandas.tseries.offsets import (Nano, Micro, Milli, Second, # noqa
Minute, Hour,
Day, BDay, CDay, Week, MonthBegin,
Minute, Hour, Day, BDay, CDay,
WeekBegin, Week, MonthBegin,
MonthEnd, BMonthBegin, BMonthEnd,
QuarterBegin, QuarterEnd, BQuarterBegin,
BQuarterEnd, YearBegin, YearEnd,
Expand Down Expand Up @@ -398,6 +398,7 @@ def _get_freq_str(base, mult=1):
'Q': 'Q',
'A': 'A',
'W': 'W',
'WS': 'W',
'M': 'M'
}

Expand All @@ -414,6 +415,7 @@ def _get_freq_str(base, mult=1):
_days = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']
for _d in _days:
_offset_to_period_map['W-%s' % _d] = 'W-%s' % _d
_offset_to_period_map['WS-%s' % _d] = 'WS-%s' % _d


def get_period_alias(offset_str):
Expand All @@ -423,6 +425,7 @@ def get_period_alias(offset_str):

_lite_rule_alias = {
'W': 'W-SUN',
'WS': 'WS-MON',
'Q': 'Q-DEC',

'A': 'A-DEC', # YearEnd(month=12),
Expand Down
7 changes: 6 additions & 1 deletion pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'YearBegin', 'BYearBegin', 'YearEnd', 'BYearEnd',
'QuarterBegin', 'BQuarterBegin', 'QuarterEnd', 'BQuarterEnd',
'LastWeekOfMonth', 'FY5253Quarter', 'FY5253',
'Week', 'WeekOfMonth', 'Easter',
'WeekBegin', 'Week', 'WeekOfMonth', 'Easter',
'Hour', 'Minute', 'Second', 'Milli', 'Micro', 'Nano',
'DateOffset']

Expand Down Expand Up @@ -1643,6 +1643,10 @@ def _from_name(cls, suffix=None):
return cls(weekday=weekday)


class WeekBegin(Week):
_prefix = 'WS'


class WeekDay(object):
MON = 0
TUE = 1
Expand Down Expand Up @@ -2955,6 +2959,7 @@ def generate_range(start=None, end=None, periods=None,
SemiMonthEnd, # 'SM'
SemiMonthBegin, # 'SMS'
Week, # 'W'
WeekBegin, # 'WS'
Second, # 'S'
Minute, # 'T'
Micro, # 'U'
Expand Down