Hi I have a data frame which has the following values as input
{1,20,21,10,100,1000,30}
I need the output to be sorted as {1,10,100,1000,20,21,30}
What is the best way to do this, I have more than 20000 values to be sorted in the above format.
I tried sort_values but its not helping .
Thanks
Given a series of the form:
To lex-sort this series, you'd need to first cast to string and then call
sort_values
.In the case of a dataframe, you'd have to do something similar:
As an improvement to this, I'd recommend argsort for the task, followed by a little indexing magic with
iloc
.With this approach, you don't have to persist the cast before a
sort_values
call.