[問題] python pandas time shift

作者: dreler1 (....)   2015-07-01 07:47:31
I have a set of data with date formate in dd/mm/YY HH:MM
I try to separate the data into weekday and weekend.
Therefore, I add a column as weekday to my data called df
temp = pd.DatetimeIndex(df['date'])
df['weekday'] = temp.weekday
It works fine, but it recognize the date as mm/dd/YY HH:MM
then I tried
df['DATE'] = datetime.datetime.strptime(df['date'], "%d/%m/%Y %HH:%MM")
.strftime("%m-%d-%Y %HH:%MM")
However, an error comes out
must be string, not Series,
Is there any way to let the program read date correctly?
Best,

Links booklink

Contact Us: admin [ a t ] ucptt.com