I have a simple data frame:
D <- c("2012/12/14", "2012/12/14")
Time <- c("18:40:37", "18:40:48")
df1 <- data.frame(D, Time)
I wish to combine the two columns of date and time information into one, preferable in the format of day, month, year, time.
How would I go about doing this?
Pandas Combine() Function combine() function which allows us to take a date and time string values and combine them to a single Pandas timestamp object. The function accepts two main parameters: Date – refers to the datetime. date object denoting the date string.
To combine the date and time columns into one column, the following formula can help you: 1. Enter this formula: =concatenate(text(A2,"mm/dd/yyyy")&" "&text(B2,"hh:mm:ss")) into a blank cell where you want to put the combined result, then press Enter key to get the first combined cell.
R> within(df1, { timestamp=format(as.POSIXct(paste(D, Time)), "%d/%m/%Y %H:%M:%S") })
D Time timestamp
1 2012/12/14 18:40:37 14/12/2012 18:40:37
2 2012/12/14 18:40:48 14/12/2012 18:40:48
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With