Skip to content
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 1Week 2Week 3
500040004000
590030005800
650050003500
350055002500
400030003000
530043005300
790059006000
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
🔒 Locked · start free trial →

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

  1. pd.read_csv("MelaSales.csv") loads Table 4.6's three week-columns into a DataFrame -- no manual column extraction needed.
  2. 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.
  3. plt.title/xlabel/ylabel label 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.