0

Data frame df contains two column, a Time:Date column and a Time:Time column and I need to merge this into a single column as a header called Date:Time

Data frame df contains the below data currently

    Time:Date    Time:Time
0  03/28/2018  10:00:00 AM
1  03/28/2018  10:01:00 AM
2  03/28/2018  10:02:00 AM
3  03/28/2018  10:03:00 AM
4  03/28/2018  10:04:00 AM

I am expecting output like below.

    Date:Time
0  03/28/2018 10:00:00 AM
1  03/28/2018 10:01:00 AM
2  03/28/2018 10:02:00 AM
3  03/28/2018 10:03:00 AM
4  03/28/2018 10:04:00 AM

Could someone please tell me simplest way to achieve this.

sacuL
  • 49,704
  • 8
  • 81
  • 106
Rafiq Shaikh
  • 103
  • 1
  • 2
  • 11

1 Answers1

3

Try something like this:

df['new_column'] = df['Time:Date']+' '+df['Time:Time']

Which just concatenates the two columns.

Furthermore, you can cast that to datetime using :

df['new_column'] = pd.to_datetime(df['Time:Date']+' '+df['Time:Time'])
sacuL
  • 49,704
  • 8
  • 81
  • 106