简体   繁体   中英

In python, how do I convert my string date column to date format using pandas?

I am unable to convert my date column from my data frame from a string to date format. I've tried using the lambda date conversion code in the image above, as well as a few other methods and I can't seem to make it work. It appears to possibly be because my 'variable' column does not appear to be like the rest of the columns (I think that it is maybe "indexed?"). Help would be much appreciate!

enter image description here在此处输入图片说明
在此处输入图片说明

使用to_datetime

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM