Created
March 30, 2021 00:09
-
-
Save bkaankuguoglu/c40bbe8a204e192799f19aa65abfc2a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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