خرید بک لینک

Vote count: 0

I have the foll. dataframe:

              Country_FAO            type   mean_area
0             Afghanistan             car   2029000.0
1             Afghanistan             car    112000.0
2                 Algeria             bus    827000.0
3                 Algeria             bus      2351.0
4               Australia             car   6475695.0
5               Australia             car  12141000.0
6               Australia             bus    293806.0

I would like to reorder this dataframe on the basis of sum of mean_areafor each value in the Country_FAO column. The end result should look like this:

              Country_FAO            type   mean_area
0               Australia             car  12141000.0
1               Australia             car   6475695.0
2               Australia             bus    293806.0
3             Afghanistan             car   2029000.0
4             Afghanistan             car    112000.0
5                 Algeria             bus    827000.0
6                 Algeria             bus      2351.0

Australia comes first because the sum of mean_area values for its 3 categories is the highest.

I tried this:

df_stacked.sort(['Country_FAO', 'mean_area'], ascending=[False, False])

This does not work though, it does not add up all the mean_areas before doing the sort.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 2 ارديبهشت 1395 ساعت: 4:05

صفحه بندی