Pandas Holidays to Dataframe with Holiday Name

Viewed 4516

This is my code so far:

year = 2012
start = datetime.date(year, 1, 1)
end = start + pd.offsets.MonthEnd(72)

class FrBusinessCalendar(AbstractHolidayCalendar):
""" Custom Holiday calendar 
"""
rules = [
    Holiday('New Years Day', month=1, day=1),
    #USThanksgivingDay,
    Holiday('Fourth Of July', month=7, day=4),
    Holiday('Thanksgiving', month=11, day=1, offset=DateOffset(weekday=TH(4))),
    Holiday('Black Friday', month=11, day=1, offset=pd.DateOffset(weekday=FR(4))),
    Holiday("Cyber Monday", month=11, day=1, offset=[pd.DateOffset(weekday=SA(4)), pd.DateOffset(2)]),
    Holiday('Christmas Day', month=12, day=25)
]

cal = FrBusinessCalendar()
# Getting the holidays (off-days) between two dates
cal.holidays(start=start, end=end)

Now, what I want to do is get all these dates into a dataframe with the name of the holiday as one column and the date as the other column. So for my example...

date           holiday
2012-01-01     New Years Day
2012-07-04     Fourth Of July
2012-11-22     Thanksgiving
....etc
1 Answers
Related