行处理——排序

基于pandas

ascending_fat_then_ascending_sodium = food_info.sort(["Lipid_Tot_(g)", "Sodium_(mg)"], ascending=[True, True])
#get the first three food 
top_three_foods = list(ascending_fat_then_ascending_sodium["Shrt_Desc"].iloc[0:3])

 输入:dataframe

 输出:sorted dataframe

 

#series
series_film=fandango['FILM']
series_rt=fandango['RottenTomatoes']
#use film names as index
series_custom = Series(series_rt.values,index= series_film.values)
#sort by index or value
sc2=series_custom.sort_index()
sc3=series_custom.sort_values()

输入:series

输出:series

你可能感兴趣的:(行处理——排序)