I have a dataframe and it has few columns.
I want to plot the top 10 countries with highest life expectancy rate.
Here is my dataset
It should be in matplotlib or seaborn.
I have a dataframe and it has few columns.
I want to plot the top 10 countries with highest life expectancy rate.
Here is my dataset
It should be in matplotlib or seaborn.
Use DataFrame.nlargest
with DataFrame.plot.bar
:
(df.nlargest(10, 'Life expectancy(years)(Country)')
.plot.bar(x='City', y='Life expectancy(years)(Country)'))
For seaborn use seaborn.barplot
:
import seaborn as sns
sns.barplot(x='City',
y='Life expectancy(years)(Country)',
data=df.nlargest(10, 'Life expectancy(years)(Country)'))