1

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)
Jamiu S.
  • 5,257
  • 5
  • 12
  • 34
bryd
  • 13
  • 4
  • https://stackoverflow.com/questions/37787698/how-to-sort-pandas-dataframe-from-one-column This can help you to sort the items. It might solve your problem. – Ajay Pun Magar Sep 20 '22 at 14:53

0 Answers0