Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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