मराठी

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

Advertisements
Advertisements

प्रश्न

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.

कोड लेखन
Advertisements

उत्तर

import pandas as pd
import matplotlib.pyplot as plt
data = {
    'College': ['Hindu College', 'Hansraj College', 'Miranda House', 'Ramjas College'],
    'Science': [8, 7, 6, 5],
    'Commerce': [3, 4, 2, 3],
    'Humanities': [10, 8, 9, 7]
}
df = pd.DataFrame(data)
df.to_csv("college_courses.csv", index=False)
df = pd.read_csv("college_courses.csv")
df.plot(x='College', y=['Science','Commerce','Humanities'], 
        kind='bar', color=['blue','green','orange'])
plt.title("Number of Courses Offered by Colleges")
plt.xlabel("Colleges")
plt.ylabel("Number of Courses")
plt.show()

Output:
A bar graph will be displayed showing the number of Science, Commerce, and Humanities courses offered by different colleges. The data is first stored in a CSV file named college_courses.csv.

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 4: Plotting Data using Matplotlib - Exercise [पृष्ठ १३५]

APPEARS IN

एनसीईआरटी Informatics Practices [English] Class 12
पाठ 4 Plotting Data using Matplotlib
Exercise | Q 11. | पृष्ठ १३५
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×