0

I want to concatenate two dataframes, but they each have two columns that are datetime objects. One is formatted YYYY-MM-DD HH:mm:SS while in the other dataframe it is formateed MM/DD/YEAR HH:mm:SS. Is there way I can convert one format to the other, I am not picky on which one I end up with in the end.

start_time
2018-12-31 23:59:18

and

start_time
4/1/2017 00:13:24

Thanks!

Brad Solomon
  • 38,521
  • 31
  • 149
  • 235

1 Answers1

0

You can convert the format like this

import datetime

date_time_str = '2018-12-31 23:59:18'  
date_time_obj = datetime.datetime.strptime(date_time_str, '%Y-%m-%d %H:%M:%S')

date_time_str2 = date_time_obj.strftime('%d/%m/%Y %H:%M:%S')
print(date_time_str2)

Output : 31/12/2018 23:59:18

gameon67
  • 3,981
  • 5
  • 35
  • 61