Q. Consider following DataFrame prodf.

	Fruits	Pulses	Rice	Wheat
Andhra P.	7830.0	931.0	7452.4	NaN
Gujarat	11950.0	818.0	1930.0	2737.0
Kerala	113.1	1.7	2604.8	NaN
Punjab	7152.0	33.0	11586.2	16440.5
Tripura	44.1	23.2	814.6	0.5
Uttar P.	24169.2	2184.4	13754.0	30056.0

Write a program to plot a scatter chart with the columns Fruits and Pulses.


Answer :-

import matplotlib.pyplot as plt
import pandas as pd

x = {"Fruits": [7830.0,11950.0,113.1,7152.0,44.1,24169.2],
     "Pulses": [931.0,818.0,1.7,33.0,23.2,2184.4],
     "Rice": [7452.4,1930.0,2604.8,11586.2,814.6,13754.0],
     "Wheat": ['NaN',2737.0,'NaN',16440.5,0.5,30056.0]}

prodf = pd.DataFrame(x)
plt.scatter (x = range (1, len (prodf)+1), y = prodf.Pulses)
plt.scatter (x = range (1, len (prodf)+1), y = prodf.Fruits)

plt.xlabel("X values")
plt.ylabel("Fruits and Pulses production")

plt.show()


Output :-

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post