Use Python/Pandas to find top 20 items by sales

Viewed 30

I am trying to identify the top 20 books by sales from a CSV file using Python/Pandas.

So far what I have is working, however, I want to include the column 'Product Name' in the results. How would I add that to this query?

Also, is there a way to sort these items by sales from highest to lowest?

Here is the query I have:

import pandas as pd

df = pd.read_csv('books.csv')
df['Sales'].value_counts().nlargest(20)
0 Answers
Related