0

I have this column in a pandas dataframe:

 dataset['Start Pump Time']:
 0        10:50
 1        14:25
 2        03:00
 3        21:15
 4        02:05
 Name: Start Pump Time, Length: 94052, dtype: object`

and this one

dataset['Start Pump Date']
0       2018-12-12
1       2018-12-16
2       2019-01-14
3       2019-05-06
4       2019-06-28
Name: Start Pump Date, Length: 94052, dtype: datetime64[ns]

I want merge those two columns and create a column that has both the date and the time and delete the previous two colums. I have tried with pandas.to_datetime but my inexperience hasn't helped in finding the correct solution till now. Thanks

  • did you try options described [here](https://stackoverflow.com/questions/17978092/combine-date-and-time-columns-using-python-pandas)? – FObersteiner Sep 23 '20 at 13:34

2 Answers2

0
pd.to_datetime(df['Start Pump Date'] + ' ' + df['Start Pump Time'])

check here Combine Date and Time columns using python pandas

RKG
  • 87
  • 4
0

Convert the other column to timedelta and add:

pd.to_timedelta(dataset['Start Pump Time'] + ":00") +  dataset['Start Pump Date']
Quang Hoang
  • 146,074
  • 10
  • 56
  • 74