pydit.wrangling.calendar_table.create_calendar

pydit.wrangling.calendar_table.create_calendar(start='1975-01-01', end='2050-12-31')[source]

Function to create a calendar DataFrame to be used as a lookup table

This can be used when doing facets/aggregation, similar to the usual calendar table in in PowerBI.

Parameters:
  • start (str or datelike optional, default: "1975-01-01") – The start date of the calendar.

  • end (str or datelike optional, default: "2050-12-31") – The end date of the calendar (included).

Returns:

A dataframe with the calendar dates and fields for:
  • year, int

  • month, int

  • day, int

  • week, int

  • quarter, int

  • day_of_year, int

  • weekday_index (0=Monday, 6=Sunday)

  • weekday (1=Monday, 7=Sunday)

  • weekday_name, str

  • weekday_name_short, str

  • weekend (True/False), bool

  • yyyymmdd, int

  • yyyymm (month number), int

  • yyyyww (week number), int

  • yyyyq (quarter), int

  • bom (beginning of month), datetime

  • eom (end of month), datetime

  • eod (end of day, ie 1 milisecond before midnight), datetime

  • date_date (date as datetime.date)

  • is_bof (True/False), bool

  • is_eom (True/False), bool

  • isoformat

Return type:

pandas.DataFrame