Module- 3 ,Challenge exercise!

Hello, I need some help with this.

Ask the LLM to help you create a pie chart of the data showing how many cars were sold each year.

Here is the code:
import pandas as pd

Dataset adapted from here Vehicle dataset | Kaggle

data = pd.read_csv(‘car_data.csv’)
print(data)
Model Price Year Kilometer
0 Honda Amaze 1.2 VX i-VTEC 5050.00 2017 87150
1 Honda Brio V MT 3510.00 2014 39276
2 Honda WR-V VX MT Petrol 8199.99 2018 27963
3 Honda CR-V 2.4 AT 8600.00 2013 67000
4 Honda Brio S MT 4400.00 2016 50374
… … … … …
153 Honda Accord 2.4 iVtec AT 1950.00 2008 57885
154 Honda City SV Diesel 7500.00 2018 75000
155 Honda City V 7300.00 2016 51834
156 Honda City SV CVT 5900.00 2015 116592
157 Honda City V 4800.00 2015 49000

[158 rows x 4 columns]

What I don’t understand is that we only have the model years of the cars, not the years they were sold. So how can I create this chart?

You are printing only one column of the dataset, if you go to the Kaggle link
that you give us, it has more columns of data, including the year.

1 Like

Thank you so much.
But why we get the table with only model, price, year, and kilometer with this code then and not the other columns?:
data = pd.read_csv(‘car_data.csv’)
print(data)
And how can I get the ther columns because I need that to use for creating a pie chart.

the data is there, is just not being displayed, you can explore as with:

Methods to Display and Explore Columns in a Dataset

  1. Show All Columns (No truncation)
print(data.to_string())  
  • Ensures the full DataFrame is printed without column cuts.
  1. List Column Names
print(data.columns)  
  • Displays all column names to check if any are hidden.
  1. Change Display Settings (Persistent solution)
pd.set_option('display.max_columns', None)
print(data)
  • Allows all columns to be printed even in large datasets.
  1. Preview First Few Rows
print(data.head())  
  • Displays the first 5 rows with all available columns.

These methods help you fully explore and display your dataset efficiently. :rocket: