Group by and find top n value_counts pandas

后端 未结 4 1505
终归单人心
终归单人心 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:54

    df['Neighborhood'].groupby(df['Borough']).value_counts().head(5)

    head() gets the top 5 rows in a data frame.

提交回复
热议问题