'How do I plot top 10 Cities with highest life expectancy rate
Solution 1:[1]
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)'))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

