Calendar.dayof¶
- Calendar.dayof(frequency: str, *, base: int = 1)¶
Returns a
datemapmapping dates to their index in the given frequency.- The frequency can be one of:
Wfor day of week (assumes week starts on Monday)W-MONfor day of week (assumes week starts on Monday)W-TUEfor day of week (assumes week starts on Tuesday)W-WEDfor day of week (assumes week starts on Wednesday)W-THUfor day of week (assumes week starts on Thursay)W-FRIfor day of week (assumes week starts on Friday)W-SATfor day of week (assumes week starts on Saturday)W-SUNfor day of week (assumes week starts on Sunday)Mfor day of monthQfor day of quarterTfor day of trimesterHfor day of semester (half year)Yfor day of year
- Parameters:
frequency (str) – the frequency
base (int) – the index of the first day each frequency
- Returns:
The datemap
- Return type:
Note
The default base is 1
Note
As the Calendar is immutable, the datemap is cached for efficiency. Repeatedly calling
calendar.dayof("M")should be of complexity 1 after the first call.Example
>>> calendar = Calendar(dates) >>> calendar.dayof("M")[datetime.date(2021,1,3)] 1