[英]Change all row values in Pandas dataframe in date format “mm/dd/yyyy” to “yyyy-mm-dd”
Like the title states, I have two csv files I have read into a Pandas dataframe and I want to join the two tables on their "Dates" column values. 像标题状态一样,我有两个csv文件,我已将其读入Pandas数据框中,并且希望将两个表连接到其“日期”列值上。 I'm having an issue converting the special character "/" to "-" and switching the ordering to year-month-day.
我在将特殊字符“ /”转换为“-”并将顺序切换为年-月-日时遇到问题。 Any easy quick way that will convert all the row values from the "mm/dd/yyyy" format to the correct "yyyy-mm-dd" format for the join?
任何简单快速的方法都可以将所有行值从“ mm / dd / yyyy”格式转换为联接的正确“ yyyy-mm-dd”格式?
When you read your csv adding parse_dates
当您阅读csv时添加
parse_dates
pd.read_csv('q.csv',parse_dates=True)
Or 要么
pd.read_csv('q.csv',parse_dates=['Dates'])# your date format column here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.