How can i split 'Date' column into 'Date' and 'Time' column? [closed]

一曲冷凌霜 提交于 2019-12-23 03:47:50

问题


In the image shown, how can i split 'Date' column into 'Date' and 'Time' column?

'


回答1:


You can use str.split by whitespace what is default separator:

df = pd.DataFrame({'Date':['4/1/2016 0.00','4/2/2016 0.05']})
print (df)
            Date
0  4/1/2016 0.00
1  4/2/2016 0.05

df[['Date','Time']] = df.Date.str.split(expand=True)
print (df)
       Date  Time
0  4/1/2016  0.00
1  4/2/2016  0.05


来源:https://stackoverflow.com/questions/42018180/how-can-i-split-date-column-into-date-and-time-column

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!