Informatics Practices
Given a data frame df1 as shown below :
| 1990 | 2000 | 2010 | |
|---|---|---|---|
| a | 52 | 340 | 890 |
| b | 64 | 480 | 560 |
| c | 78 | 688 | 1102 |
| d | 94 | 766 | 889 |
Write code to create a bar chart plotting the three columns of dataframe df1.
PyPlot
2 Likes
Answer
import matplotlib.pyplot as plt
data = {'1990': [52, 64, 78, 94],
'2000': [340, 480, 688, 766],
'2010': [890, 560, 1102, 889]}
df1 = pd.DataFrame(data, index=['a', 'b', 'c', 'd'])
df1.plot(kind = 'bar')
plt.show()
Output

Answered By
3 Likes
Related Questions
Given a data frame df1 as shown below :
1990 2000 2010 a 52 340 890 b 64 480 560 c 78 688 1102 d 94 766 889 Write code to create a scatter chart from the 1990 and 2010 columns of dataframe df1.
Given a data frame df1 as shown below :
1990 2000 2010 a 52 340 890 b 64 480 560 c 78 688 1102 d 94 766 889 Write code to create a line chart from the 1990 and 2000 columns of dataframe df1.
The score of four teams in 5 IPL matches is available to you. Write a program to plot these in a bar chart.
The score of a team in 5 IPL matches is available to you. Write a program to create a pie chart from this data, showing the last match's performance as a wedge.