how to change index date format pandas

39

df['Datetime'] = pd.to_datetime(df['date'] + ' ' + df['time'])
df = df.set_index('Datetime')
df.index = df.index.strftime('%d/%m/%Y')
print (df)
            Col1  Col2
10/02/2017  val1  val1
09/02/2017  val2  val2
08/02/2017  val3  val3
07/02/2017  val4  val4

print (type(df.index[0]))
<class 'str'>

Comments

Submit
0 Comments