Programs · Program 4-4
Q.
(Program 4-4) Smile NGO has participated in a three week cultural mela. Using Pandas, they have stored the sales (in Rs) made day wise for every week in a CSV file named "MelaSales.csv", as shown in Table 4.6.
Table 4.6 -- day-wise mela sales (in Rs):
| Week 1 | Week 2 | Week 3 |
|---|---|---|
| 5000 | 4000 | 4000 |
| 5900 | 3000 | 5800 |
| 6500 | 5000 | 3500 |
| 3500 | 5500 | 2500 |
| 4000 | 3000 | 3000 |
| 5300 | 4300 | 5300 |
| 7900 | 5900 | 6000 |
| Depict the sales for the three weeks using a Line chart. It should have the following: (i) chart title as "Mela Sales Report" (ii) x axis label as "Days" (iii) y axis label as "Sales in Rs". Line colours are red for week 1, blue for week 2 and brown for week 3. |
Yanam BieapTextbookSubjective· 4mImportance★★★★★est
16% · 7/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 →Read MelaSales.csv into a DataFrame and let pandas plot all its numeric columns as a line chart in one call.
import pandas as pd
import matplotlib.pyplot as plt
df=pd.read_csv("MelaSales.csv")
df.plot(kind='line', color=['red','blue','brown'])
plt.title('Mela Sales Report')
plt.xlabel('Days')
plt.ylabel('Sales in Rs')
plt.show()
df.plot(kind='line', ...) plots every numeric column of the DataFrame in one call -- there's no need to call plt.plot() separately for each week.
Step by step
pd.read_csv("MelaSales.csv")loads Table 4.6's three week-columns into a DataFrame -- no manual column extraction needed.df.plot(kind='line', color=[...])plots EVERY numeric column (Week 1, Week 2, Week 3) as its own line in one call, coloured red/blue/brown in that column order.plt.title/xlabel/ylabellabel the chart exactly as the question specifies. …
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.