Skip to content

Instantly share code, notes, and snippets.

@lppier
Last active February 21, 2019 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lppier/bc8a323c7434319ad7f8e2f5212d77b3 to your computer and use it in GitHub Desktop.
Save lppier/bc8a323c7434319ad7f8e2f5212d77b3 to your computer and use it in GitHub Desktop.
Converting datetime to day of week
import calendar
df_weekly_season['DOW_ENG'] = weekly_season['ds'].apply(lambda x : calendar.day_name[pd.to_datetime(x).weekday()])
df_weekly_season['DOW'] = weekly_season['ds'].apply(lambda x : int(pd.to_datetime(x).strftime('%w'))) # SUN == 0
df_weekly_season['DOW'] = weekly_season['ds'].apply(lambda x : int(pd.to_datetime(x).weekday()) # MON == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment