简体   繁体   English

Pandas 按聚合列命名组

[英]Pandas Naming Group by aggregated column

I'm trying to summarize a dataset of top 50 novels sold.我正在尝试总结销售前 50 部小说的数据集。 I want to create a table of authors and the numbers of book they have written.我想创建一个作者表和他们写的书的数量。 I used the following code:我使用了以下代码:

df.Author.value_counts().sort_values(ascending  =  False)

how can I name the column that lists the value count for each author?如何命名列出每个作者的值计数的列?

You can check below snippet您可以查看以下代码段

top_50= [x for x in df.Author.value_counts().sort_values(ascending=False).head(50).count()]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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