You can do something like this:
from datetime import datetime
def get_weekday(row):
date_str = "{}-{}-{}".format(row["Year"], row["Month"], row["Day"])
date = datetime.strptime(date_str, '%Y-%m-%d')
return date.weekday()
df2019["weekday"] = df2019.apply(get_weekday, axis=1)
Since your Timestamp
is already of datetime
format, you can do this:
df2019['weekday'] = df2019['Timestamp'].dt.weekday
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.