I have this: 2017-01-09 23:14:06+00:00
I want this: 09/01/2017
How can i do it in a column (date_of_birth) of DataFrame in in Python?
df = pd.DataFrame({
'name': ['alice','bob','charlie'],
'date_of_birth': ['2017-01-04 17:52:30+00:00','2017-01-04 17:52:35+00:00','2017-01-04 17:53:03+00:00 ']
})
Thanks!
Parse the datetime column with pd.to_datetime
and use Series.dt.strftime
:
df['date_of_birth'] = pd.to_datetime(df.date_of_birth).dt.strftime('%d/%m/%Y')
print(df)
name date_of_birth
0 alice 04/01/2017
1 bob 04/01/2017
2 charlie 04/01/2017
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments