Calendar.dayof#

Calendar.dayof(frequency: str, *, base: int = 1)#

Returns a datemap mapping dates to their index in the given frequency.

The frequency can be one of:
  • W for day of week (assumes week starts on Monday)

  • W-MON for day of week (assumes week starts on Monday)

  • W-TUE for day of week (assumes week starts on Tuesday)

  • W-WED for day of week (assumes week starts on Wednesday)

  • W-THU for day of week (assumes week starts on Thursay)

  • W-FRI for day of week (assumes week starts on Friday)

  • W-SAT for day of week (assumes week starts on Saturday)

  • W-SUN for day of week (assumes week starts on Sunday)

  • M for day of month

  • Q for day of quarter

  • T for day of trimester

  • H for day of semester (half year)

  • Y for day of year

Parameters:
  • frequency (str) – the frequency

  • base (int) – the index of the first day each frequency

Returns:

The datemap

Return type:

datemap

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