Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Basically, I have a dataset with car models and I need a bar graph where the highest review count of 20 car brands should be displayed in the bar graph!

I have tried this below code but I am getting all the brand models from the dataset I need only the top 20 highest review count car brands in the bar graph.

Used Dataset: https://www.kaggle.com/datasets/tr1gg3rtrash/cars-2022-dataset?group=owned

What I have tried:

#Data.plot.bar()
plt.figure(figsize=(30,9))
x_zoom = np.linspace(-1, 1, 50)
y_zoom = np.sin(x_zoom)
plt.bar(Data['car_name'], Data['reviews_count'])
plt.xlabel("car name")
plt.ylabel("Review Count")
plt.show() 
Posted
Comments
OriginalGriff 22-Nov-22 4:22am    
And?
What have you tried?
Where are you stuck?
What help do you need?

Use the "Improve question" widget to edit your question and provide better information.
Richard MacCutchan 22-Nov-22 4:37am    
You need to add a filter, or sort, to extract the top 20 before you pass them to the plot.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900