0

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

2 Answers2

0

Use this conversion:

df['c0'] = pd.to_datetime(df['c0']).dt.date
Michael
  • 4,879
  • 2
  • 10
  • 32
0

You can convert it to datetime type and use the strftime() method to change the date format.

df['c0'] = pd.to_datetime(df['c0']).dt.strftime('%Y-%d-%m')
Ynjxsjmh
  • 16,448
  • 3
  • 17
  • 42