0

I am new to python and ne of my data sets has date and time in separate columns. both are in bject type. So I tried to combine them into datetime format through the below line

df1.loc[:,'date'] = pd.to_datetime(df1.date.astype(object) + ' ' + df1.time.astype(object))

It gives me an error unsupported operand type(s) for +: 'int' and 'str'

I understand that data is in object type so + operator is not able to combine them but I am not sure how to combine object type to date time. Any help to do the same would be great. Thanks

FObersteiner
  • 22,500
  • 8
  • 42
  • 72

1 Answers1

0

Have you tried to convert the two objects type to string,

How to convert column with dtype as object to string in Pandas Dataframe

and then concatenate the two strings and then apply pd.to_datetime()

Eoin Brennan
  • 131
  • 7