[問題] python pandas time shift
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://www.ptt.cc/bbs/Programming/M.1435708054.A.57C.html
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章