Skip to content

Instantly share code, notes, and snippets.

@bkaankuguoglu
Created March 30, 2021 00:09
Show Gist options
  • Save bkaankuguoglu/c40bbe8a204e192799f19aa65abfc2a9 to your computer and use it in GitHub Desktop.
Save bkaankuguoglu/c40bbe8a204e192799f19aa65abfc2a9 to your computer and use it in GitHub Desktop.
from datetime import date
import holidays
us_holidays = holidays.US()
def is_holiday(date):
date = date.replace(hour = 0)
return 1 if (date in us_holidays) else 0
def add_holiday_col(df, holidays):
return df.assign(is_holiday = df.index.to_series().apply(is_holiday))
df_features = add_holiday_col(df_features, us_holidays)
df_features
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment