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 line chart from the 1990 and 2000 columns of dataframe df1.
PyPlot
3 Likes
Answer
import pandas as pd
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'])
plt.plot(df1['1990'], df1['2000'])
plt.show()
Output

Answered By
3 Likes
Related Questions
Consider the following graph. Write the Python code to plot it. Also add the Title, label for X and Y axis.

Using the following data for plotting the graph
smarks = [10, 40, 30, 60, 55] sname = ["Sahil", "Deepak", "Anil", "Ravi", "Riti"]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 bar chart plotting the three 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.