Pandas Naming Group by aggregated column

Viewed 30

I'm trying to summarize a dataset of top 50 novels sold. 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?

1 Answers

You can check below snippet

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

Related