Max Murphy
0
Q:

python datetime weekday

from datetime import datetime
date_str='10-12-20'
datetime_object = datetime.strptime(date_str, '%m-%d-%y')
datetime_object.weekday()
0
import datetime
date = datetime.datetime.now()
''' return datetime object
Attributes:
	year 
    month
    day
    hour
    minute
    second
    microsecond
    
date.weekday() return the weekday from 0 to 6 where Monday = 0
'''  
1
df['date_time'].dt.dayofweek #gives only the index(0-monday,6-sunday)
df['date_time'].dt.weekday_name #gives the day
0

New to Communities?

Join the community