简体   繁体   中英

Python : change datetime format

I have this Pandas dataframe:

在此处输入图像描述

I want to change date format from "%d/%m/%y" to "%m/%d/%y"

all_data["Date demande1"]=all_data["Date demande"].apply(lambda x: datetime.strftime(pd.to_datetime(x), "%m/%d/%Y"))

I tried this function, it works with certain lines and others not??

在此处输入图像描述

all_data["Date demande1"]=all_data["Date demande"].apply(lambda x: datetime.strftime(pd.to_datetime(x, format="%d/%m/%Y %H:%M", errors='ignore'), "%m/%d/%Y"))

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