作者dreler1 (....)
站内Programming
标题[问题] python pandas time shift
时间Wed Jul 1 07:47:31 2015
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,
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 134.197.56.9
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Programming/M.1435708054.A.57C.html