# Exercise on Pandas DataFrame Plots

Pandas , Pandas plot

1. Read the data from Excel table and plot a line graph showing Number of students in each class.
2. Plot bar graph showing Class and its Mean mark of each class.
3. Plot bar graph showing Class and its Mean mark and Maximum mark of each class.
4. Create a Pie chart showing Class and number of students.
5. Create a density plot by using Mark
Solution 1
``````import pandas as pd
df=my_data['class1'].value_counts()
#print(my_out)
df.plot.line(title="Class and number of Marks");``````
Solution 2
``````import pandas as pd
df=my_data[['class1','mark']].groupby(['class1']).agg(['mean'])
df.plot.bar(title="Class1 and Mean mark");``````
Solution 3
``````import pandas as pd
df=my_data[['class1','mark']].groupby(['class1']).agg(['mean','max'])
df.plot.bar(title="Class with Mean and Max mark");``````
Solution 4
``````import pandas as pd
df=my_data['class1'].value_counts()
#print(my_out)
df.plot.pie(title="Class with number of students");``````
Solution 5
``````import pandas as pd
df=my_data['mark']
#print(my_out)
df.plot.density(title="Mark Density");``````

Plotting graphs using DataFrame
 plot-line Plotting line graph with different options plot-bar Plotting bar graph with different options plot-barh Plotting Horizontal bar graph with different options plot-hist Histogram with different options plot-boxplot boxplot with different options plot-pie Pie diagram with different options plot-density Density diagram with different options plot-area Area diagram with different options plot-scatter Scatter plot with different options

Subscribe to our YouTube Channel here

## Subscribe

* indicates required
Subscribe to plus2net

plus2net.com