def get_holiday_df(year,month):
monthRange = calendar.monthrange(year,month)[-1]
mask_month = "%s%s"%(year,month)
if month < 10:
mask_month = "%s0%s"%(year,month)
mask = get_holiday_mask(mask_month)
a = pd.DataFrame(index = pd.date_range('%s-%s-1'%(year,month), periods=monthRange, freq='D'))
index = pd.Series(a.index)
mask_df = index.apply(lambda x:mask[x.day] if x.day in mask else 0)
mask_df.index = index
a['holiday'] = (mask_df == 1).astype('int')
a['festday'] = (mask_df == 2).astype('int')
return a
评论列表
文章目录