Use app×
QUIZARD
QUIZARD
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE

1 Answer

+1 vote
by (51.9k points)
selected by
 
Best answer

Pie is a type of graph in which a circle is divided into different sectors and each sector represents a part of the whole. A pie plot is used to represent numerical data proportionally. To plot a pie chart, either column label y or 'subplots=True' should be set while using df.plot(kind='pie') . If no column reference is passed and subplots=True, a 'pie' plot is drawn for each numerical column independently.

In the Program we have a DataFrame with information about the planet's mass and radius. The ‘mass’ column is passed to the plot() function to get a pie plot as shown in Figure.

Program :

import pandas as pd 

import matplotlib.pyplot as plt 

df = pd.DataFrame({'mass': [0.330, 4.87 , 5.97], 

     'radius': [2439.7, 6051.8, 6378.1]}, 

     index=['Mercury', 'Venus', 'Earth']) 

df.plot(kind='pie',y='mass') 

plt.show()

Pie chart as output of Program

It is important to note that the default label names are the index value of the DataFrame. The labels as shown in Figure are the names of the planet which are the index values as shown in Program.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...