date - Concantenate two string and convert to datetime pandas python -


i using latest version of pandas , python 3.5

i have csv file 2 columns date , time both string

date: 07jan2015 time: 0:00:00 

i need concatenate date , time , convert result datetime or timestamp date must in following format

date format: 01/07/2015 

so result should this:

01/07/2015 0:00:00 

i using pandas import csv

your appreciated.

i think can use to_datetime dt.strftime:

print (df)         date     time 0  07jan2015  0:00:00 1  08jan2015  1:00:00  df['new'] = pd.to_datetime(df.date + df.time, format='%d%b%y%h:%m:%s') df['new'] = df.new.dt.strftime('%m/%d/%y %h:%m:%s')  print (df)         date     time                  new 0  07jan2015  0:00:00  01/07/2015 00:00:00 1  08jan2015  1:00:00  01/08/2015 01:00:00 

python's strftime directives.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -