Concatenating Date column and Time Column in Pandas

Nitesh Srivastava
1 min readAug 22, 2019

I was in the process of analyzing AirQuality data set. I found there are two different columns capturing Date and Time in the different column. For better understanding, I thought to make Date and Time as one column and use it as Index for easy access to data. The dataFrame.info() has given me as below:

info about data frame

i.e. Date is Date time and Time is Object (basically String). I can’t concatenate the two columns straight forward, So I tried to do the following and finally the formula came to achieve this as below:

df[“new time”]=df[“Date”].dt.strftime(‘%Y-%m-%d’).astype(‘str’) +” “+ df[“Time”].astype(‘str’)

--

--

Nitesh Srivastava

Strategic and Technical Consultant, A Cloud change enabler, helping business to meet technology for better ROI.