简体   繁体   中英

how to order values a dataframe from high to low in python

myDataTradeSWE = myDataTrade[(myDataTrade['from']=='SWE') & (myDataTrade['Year']<2015)]
myDataTradeSWE.head(10) 

this is the code of the data frame and the data it returns the "VAL" column is the one i need to order from high to low.

If you want to sort the entire DataFrame:

out = myDataTradeSWE.sort_values(by='VAL', ascending=False)

If you want to sort only VAL :

out = myDataTradeSWE['VAL'].sort_values(ascending=False)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM