- #Q1. Find the data in the dataframe below. c
- dic = {'country': ['India', 'Japan', 'China', 'USA', 'Russia'],
- 'population': [1425.7, 123.3, 1425.4, 340, 144.4],
- 'growthrate': [6.72, 1.47, 8.5, 8.8, 4.7],
- 'gdp':[3730,4231,17786,70248,12194]}
- df = pd.DataFrame(dic)
- df
- # Create Pie charts for countries with population, growthrate, and gdp. Exclude any one by 15%.
- # Sample is given below
- plt.subplot(2,2,1)
- plt.title('countries with population')
- df.groupby('country')['population'].mean().plot(kind='pie',explode=[0.15,0,0,0,0])
- plt.subplot(2,2,2)
- plt.title('countries with growthrate')
- df.groupby('country')['growthrate'].mean().plot(kind='pie',explode=[0.15,0,0,0,0])
- plt.subplot(2,2,3)
- plt.title('countries with gdp')
- df.groupby('country')['gdp'].mean().plot(kind='pie', explode=[0.15,0,0,0,0])
- # Q2. Create vertical bar charts for countries with population, growthrate, and gdp.
- # Sample is given below
- plt.subplot(2,2,1)
- plt.title("count by popula")
- df.groupby('country')['population'].mean().plot(kind='bar')
- plt.subplot(2,2,2)
- plt.title("cont by growthwte")
- df.groupby('country')['growthrate'].mean().plot(kind='bar')
- plt.subplot(2,2,3)
- plt.title("cont by gdp")
- df.groupby('country')['gdp'].mean().plot(kind='bar')
- #plt.show()
- # Q3. Do the following in matplotlib
- plt.bar(df['country'],df['population'], color='b')
- for i in range (len(df['country'])):
- plt.text(i,df['population'][i],str(df['population'][i]),ha='center', va='bottom')
- plt.show()
[text] data
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: