I've the following data from a data frame
Name,JoiningDate,AmtPaid Joe,12/31/09,1000 Amy,10/28/09,100 John,05/06/10,200
The Joining Date is coming in as a factor (when I sapply
). How can I convert this to date and then sort on JoiningDate
?
The best way to convert one or more columns of a DataFrame to numeric values is to use pandas. to_numeric() . This function will try to change non-numeric objects (such as strings) into integers or floating-point numbers as appropriate.
This should do it (where df is your dataframe)
df$JoiningDate <- as.Date(df$JoiningDate , format = "%m/%d/%y") df[order(df$JoiningDate ),]
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