Group by and find top n value_counts pandas

后端 未结 4 1511
终归单人心
终归单人心 2020-12-25 12:04

I have a dataframe of taxi data with two columns that looks like this:

Neighborhood    Borough        Time
Midtown         Manhattan      X
Melrose         B         


        
4条回答
  •  悲哀的现实
    2020-12-25 12:47

    You can also try below code to get only top 10 values of value counts

    'country_code' and 'raised_amount_usd' is column names.

    groupby_country_code=master_frame.groupby('country_code') arr=groupby_country_code['raised_amount_usd'].sum().sort_index()[0:10] print(arr)

    [0:10] shows index 0 to 10 from array for slicing. you can choose your slicing option.

提交回复
热议问题