Pandas is a popular Python-based data analysis toolkit that can be imported using
“import pandas as pd
”
It presents a diverse range of utilities from parsing multiple file-formats to converting an entire data table into a NumPy matrix array. This property makes pandas a trusted ally in data science and machine learning.
Pandas can help with the creation of multiple types of data analysis graphs. One such example is the
A pie chart is used to help someone understand the composition of something. If there is categorical data, then a pie chart will have each slice represent a different category to make it easier to understand the data.
The default implementation of pie plot is:
DataFrame.plot.pie( **kwargs)
y
: int or string - The columns label or position that needs to be plotted. If not provided, subplots=True
must be added.
**kwargs
: tuple (rows, columns) - All other plotting keyword arguments to be passed to DataFrame.plot().
The following code shows how a pie plot can be added in Python. You can change the parameters to see how the output varies.
#import libraryimport pandas as pd#add csv file to dataframedf = pd.read_csv('dataset.csv')print(df)#create pie plotpieplot = df.plot.pie(y= "Maths", figsize = (5,5), legend = False)
Free Resources