I have a question about sorting a dataframe in Pandas.
For example I have a dataframe 'df_cars' with the columns 'Year','Model','Mileage','Price'.
And I want to display the dataframe ordered by 'Year' (desc) and 'Mileage' (asc).
I know how to sort by multiple colulmns but the same order (asc/or desc):
print(df_cars.sort_values(by=['Year','Price'], inplace = False, ascending = True)
The values for 'Year' and 'Price' will be both ordered in ascending way.
But if I have several values for the same year, and want to see the years in ascending order and the prices in descending order.
What should I do?
Thanks in advance.
byfor theascendingparameter. - Nathan Furnalascending = [True, False]- David Erickson