Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ValueError: unconverted data remains: 70

df['established_date']=[datetime.datetime.strptime(x,'%d-%m-%y').strftime("%y-%m-%d") if not x=="nan" else x for x in df.established_date]

I am not getting why it is not working.

or

I am trying to convert 12-07-17 this date fromat to 2017-07-12 this format.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have written above code but it isn’t working.

>Solution :

There’s a simpler method, that’s designed for this, called pd.to_datetime:

df.established_date = pd.to_datetime(df.established_date, errors='coerce').dt.strftime('%Y-%d-%m')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading