Answers for "extract weekday from datetime pandas"

3

convert pandas datetime to day, weekday, month

#Convert datetime column/series to hour of the day. NB: Column must be in datetime format.
df['hour'] = df['column_name'].dt.hour
#Convert datetime column/series to day of the week
df['day'] = df['column_name'].dt.weekday
#Convert datetime column/series to month
df['month'] = df['column_name'].dt.month
#Convert datetime column/series to year
df['year'] = df['column_name'].dt.year
#NB: Weekday/Month will be in int. Eg. for months, January=1, February=2...etc,
Posted by: Guest on June-25-2021
4

get weekday from date python

>>> import datetime
>>> datetime.datetime.today()
datetime.datetime(2012, 3, 23, 23, 24, 55, 173504)
>>> datetime.datetime.today().weekday()
4
Posted by: Guest on June-04-2020

Code answers related to "extract weekday from datetime pandas"

Python Answers by Framework

Browse Popular Code Answers by Language