在python中,如何使用pandas将字符串日期列转换为日期格式?

时间:2018-02-17 18:47:29

标签: python date

我无法将数据框中的日期列从字符串转换为日期格式。我已经尝试在上面的图像中使用lambda日期转换代码,以及一些其他方法,我似乎无法使其工作。它似乎可能是因为我的“变量”列似乎不像其他列(我认为它可能是“索引?”)。帮助会非常感激!

enter image description here enter image description here
enter image description here

1 个答案:

答案 0 :(得分:0)

使用to_datetime

Hotsprings2['variable'] = pd.to_datetime(Hotsprings2['variable'], format='%Y-%m-%d')
相关问题