Reputation: 73
I don't know why I can't figure this out. I've tried a million different ways to do this, but no cookie.
wkdp = dte.dt.dayofweek #gives only the index(0-monday,6-sunday)
print (wkdp)
wkdp = dte.dt.dayofweek #gives only the index(0-monday,6-sunday)
print (wkdp)
0 0
1 1
2 2
3 3
4 4
..
499 2
500 3
501 4
502 0
503 1
Name: Date, Length: 504, dtype: int64
So here I can get the integer value. But I cannot change it to the day of the week string. It's a 503 column of data and some of the examples that I have seen don't use variables to convert but individual dates. Can someone help me out. I have tried
date.weekday()
and nothing. I have also tried
dp_weekday = date(date_parse).weekday()
#Convert weekday column data into string value
days =
{0:'Monday',1:'Tuesday',2:'Wednesday',3:'Thursday',4:'Friday',5:'Saturday',6:'Sunday'}
Upvotes: 0
Views: 321
Reputation: 79228
I believe you are looking for:
wkdp = dte.dt.strftime('%A')
print(wkdp)
Upvotes: 2