Concatenating Date column and Time Column in Pandas
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:
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’)