Programs · Program 4-6
Q.
(Program 4-6) Write a Python script to display a Bar plot for the "MelaSales.csv" file with column Day on x axis, titled "Mela Sales Report" and y axis labelled "Sales in Rs".
Table 4.7 -- day-wise sales data along with Day's names:
| Week 1 | Week 2 | Week 3 | Day |
|---|---|---|---|
| 5000 | 4000 | 4000 | Monday |
| 5900 | 3000 | 5800 | Tuesday |
| 6500 | 5000 | 3500 | Wednesday |
| 3500 | 5500 | 2500 | Thursday |
| 4000 | 3000 | 3000 | Friday |
| 5300 | 4300 | 5300 | Saturday |
| 7900 | 5900 | 6000 | Sunday |
West Bengal WbchseTextbookSubjective· 3mImportance★★★★★est
20% · 9/44 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →A grouped bar chart -- one call plots all three weeks as side-by-side bars per day.
import pandas as pd
df= pd.read_csv('MelaSales.csv')
import matplotlib.pyplot as plt
df.plot(kind='bar',x='Day',title='Mela Sales Report')
plt.ylabel('Sales in Rs')
plt.show()
df.plot(kind='bar', x='Day', ...) automatically draws one bar PER numeric column per day (a grouped bar chart) -- there's no need to sum the weeks into a single total.
Step by step
pd.read_csv('MelaSales.csv')loads Table 4.7, which (unlike Table 4.6) has a fourth column,Day, holding the day names.df.plot(kind='bar', x='Day', ...)tells pandas to use theDaycolumn as the category axis instead of the default row-number index -- every OTHER numeric …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.