I want to find out the following:
given a date (datetime
object), what is the corresponding day of the week?
For instance, Sunday is the first day, Mond
Say you have timeStamp: String variable, YYYY-MM-DD HH:MM:SS
step 1: convert it to dateTime function with blow code...
df['timeStamp'] = pd.to_datetime(df['timeStamp'])
Step 2 : Now you can extract all the required feature as below which will create new Column for each of the fild- hour,month,day of week,year, date
df['Hour'] = df['timeStamp'].apply(lambda time: time.hour)
df['Month'] = df['timeStamp'].apply(lambda time: time.month)
df['Day of Week'] = df['timeStamp'].apply(lambda time: time.dayofweek)
df['Year'] = df['timeStamp'].apply(lambda t: t.year)
df['Date'] = df['timeStamp'].apply(lambda t: t.day)