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

Change the format of the date to the YYYY-DD-MM in pandas dataframe

I have a dataframe as follow:

import pandas as pd
import numpy as np
df = pd.DataFrame()
df['c0'] = [ '2019-01-01 06:00:00',  '2019-01-03 06:00:00', '2019-05-03 06:00:00' ]
df['c1'] = [ 0.4452, 0.2064, 0.1416]

I want to change the format of the date as "yyyy-dd-mm". The final dataframe which I want is:

enter image description here

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

>Solution :

Use this conversion:

df['c0'] = pd.to_datetime(df['c0']).dt.date
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