I have csv data as below:
x y date time
2 4 4/5/2017 00:22:34
5 1 4/5/2017 00:22:50
. . ...... ......
. . ..... .....
so on
I converted date and time into one single datetime column and I want to insert that datetime back again into csv file or into dataframe.
output:
x y datetime
2 4 4-5-2017 00:22:34
I tried this code:
import pandas as pd
df = pd.read_csv('file.csv')
datetime = pd.to_datetime(df['date'] + ' ' + df['time'])
print(datetime)
I want to insert datetime to the df in order to write it to the csv file.