CBSE Class 12 Informatics Practices Question 54 of 73

Data Visualization using Matplotlib — Question 19

Back to all questions
19
Question

Question 19

Collect data about colleges in Delhi University or any other university of your choice and number of courses they run for Science, Commerce and Humanities, store it in a CSV file and present it using a bar plot.

Answer
import pandas as pd
import matplotlib.pyplot as plt

data = {"Stream": ["Science", "Commerce", "Humanities"], 
        "Number of Courses": [12, 10, 15] 
}

df = pd.DataFrame(data)
df.to_csv('du_colleges.csv', index=False)

df = pd.read_csv("du_colleges.csv")
plt.bar(df["Stream"], df["Number of Courses"])
plt.xlabel("Stream")
plt.ylabel("Number of Courses")
plt.title("Number of Courses in Each Stream")
plt.show()
Output
Collect data about colleges in Delhi University or any other university of your choice and number of courses they run for Science, Commerce and Humanities, store it in a CSV file and present it using a bar plot. Data Visualization using Matplotlib, Informatics Practices Preeti Arora Solutions CBSE Class 12