熊猫,从read_csv合并日期和时间列

时间:2019-03-21 14:15:10

标签: python pandas datetime

我有这个.csv文件:

"Date","Time","Open","High","Low","Close","Up","Down"
03/20/2018,17:01,2723.25,2724.50,2723.25,2723.75,372,345
03/20/2018,17:02,2723.75,2724.25,2723.50,2724.00,127,49
03/20/2018,17:03,2724.00,2724.00,2723.75,2723.75,55,11
03/20/2018,17:04,2724.00,2724.50,2724.00,2724.00,105,25

我可以这样导入Pandas:

df = pd.read_csv("C:/file.TXT", parse_dates=['Date', 'Time'], sep=",")

我现在想添加一个Datetime列以合并DateTime列。

可以在导入时完成吗?如果没有,该如何执行而不必遍历每一行?

在伪代码中,我需要这样的东西:

df['Datetime'] = # datetime(date=df['Date'], time=df['Time'])

0 个答案:

没有答案