如何将“日期”列拆分为“日期”和“时间”列? [英] How can i split 'Date' column into 'Date' and 'Time' column?

查看:119
本文介绍了如何将“日期”列拆分为“日期”和“时间”列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在显示的图片中,如何将日期列拆分为日期和时间列?

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

'

推荐答案

您可以使用 str.split 空格什么是默认分隔符:

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

这篇关于如何将“日期”列拆分为“日期”和“时间”列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆