Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Created April 25, 2020 10:33
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 aniruddha27/c366f4caade8ef3365324ab3201c794c to your computer and use it in GitHub Desktop.
Save aniruddha27/c366f4caade8ef3365324ab3201c794c to your computer and use it in GitHub Desktop.
# day
df['Day'] = df['Start_date'].dt.day
# month
df['Month'] = df['Start_date'].dt.month
# year
df['Year'] = df['Start_date'].dt.year
# hour
df['Start_hour'] = df['Start_date'].dt.hour
# minute
df['Start_minute'] = df['Start_date'].dt.minute
# second
df['Start_second'] = df['Start_date'].dt.second
# Monday is 0 and Sunday is 6
df['Start_weekday'] = df['Start_date'].dt.weekday
# week of the year
df['Start_week_of_year'] = df['Start_date'].dt.week
# duration
df['Duration'] = df['End_date']-df['Start_date']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment