📜  panda datetime ymd to dmy - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:15.865000             🧑  作者: Mango

代码示例1
df1['Date'] = pd.to_datetime(df1['Date'], format='%Y%m%d').dt.strftime('%m/%d/%Y')
df2['Date'] = pd.to_datetime(df2['Date']).dt.strftime('%m/%d/%Y')
df3['Date'] = pd.to_datetime(df3['Date']).dt.strftime('%m/%d/%Y')
df4['Date'] = pd.to_datetime(df4['Date']).dt.strftime('%m/%d/%Y')

print df1
print df2
print df3
print df4
         Date
0  03/01/2016
1  03/01/2016
2  03/01/2016
3  03/01/2016
         Date
0  01/03/2016
1  01/03/2016
2  01/03/2016
         Date
0  03/31/2016
1  03/31/2016
2  03/31/2016
         Date
0  02/25/2016
1  02/25/2016
2  02/25/2016

print type(df1.at[0,'Date'])