Drawing a Pie Chart using a Pandas Series

A pie chart is a circular statistical diagram that shows the constituent variables of a whole, as wedges in proportion to their percentage values. The pandas example plots a pie chart for a pandas Series.

Series Plotting Updated 24 Aug 2019 1 min read

Overview

  • Pie charts display how much a specific variable or quantity contributes to the whole, where the whole represents 100%.
  • Each variable is represented as a wedge.
  • The data with a value zero will not have any wedge in the pie chart.
  • Calling the pie() function of the plot member on a pandas Series instance, plots the pie chart for the Series data.

Example

python
# Example Python Program to draw a pie chart for the data

# present in a pandas Series object

import pandas as pds

import matplotlib.pyplot as plt

# Daily visitors

data = [0,120,90,120,100,80,30];

# Create a pandas series

series = pds.Series(data, index=("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"));

# Create a pie chart

series.plot.pie(label="", title="Daily visitors to the village library");

plt.show(block=True);

Output

Drawing a Pie chart for the data present in a pandas.Series