Ex No:1
➢ Using the given event_sales.csv data, create a line chart with the following
properties:
( Chart title: "Event Sales Report", X-axis label: "Days" , Y-axis label: "Sales in Rs" Plot
sales for Week 1, Week 2, and Week 3 using: Different colors)
1. Which week had the highest sales on Saturday?
2. Calculate the average sales for Week 2.
3. On which day was the difference between Week 3 and Week 1 sales the greatest?
4. Plot only Week 2 sales in purple with circle ('o') markers and dash-dot line.
5. Find the total sales across all weeks on Friday.
6. Identify the day with the lowest sales in Week 1.
7. Create a bar chart showing average sales per week.
1. Which week had the highest sales on Saturday?
(Explanation:
• data['Days'] == 'Saturday' returns a boolean mask, selecting only the row where the
day is Saturday.
• ['Week1', 'Week2', 'Week3'] selects only the columns for Week1, Week2, and Week3.
• This line gives the sales numbers on Saturday across all three weeks.
• data[data['Days'] == 'Saturday'][['Week1', 'Week2', 'Week3']] gets a 1-row DataFrame
of Saturday's sales.
• .iloc[0] extracts that single row as a Series, which makes it easier to plot.
• saturday_sales.index → ['Week1', 'Week2', 'Week3'] – these are the x-axis labels.
• saturday_sales.values → [2000, 2200, 2100] – these are the y-axis values (sales).)
2. Calculate the average sales for Week 2.
(Explanation:
• data['Days']: X-axis – Days of the week (['Monday', ..., 'Sunday'])
• data['Week2']: Y-axis – Sales values for Week 2
• label='Week 2': Line label for the legend
• color='blue': Line color
• marker='*': Adds star markers at each data point
• linestyle='--': Dashed line
• linewidth=3: Makes the line thicker
• [Link](...) adds a horizontal line at the y-value = average.
• color='gray': Line color
• linestyle=':': Dotted style for distinction
• label=...: Adds text like "Average = 1585.7" in the legend
• [Link]() shows the legend with "Week 2" and "Average" lines.
• plt.tight_layout() adjusts spacing automatically so labels and title don't overlap.))
3. On which day was the difference between Week 3 and Week 1 sales the greatest?
(Explanation:
• [Link]() finds the index of the maximum value in the diff Series.
• data['Days'][...] gets the day name corresponding to that index.
• Adds a new column W3_W1_Diff to the data DataFrame.
• X-axis: Days of the week
• Y-axis: Difference in sales between Week 3 and Week 1)
4. Plot only Week 2 sales in purple with circle ('o') markers and dash-dot line.
(Explanation:
• data['Days'] → X-axis values (e.g., ['Monday', 'Tuesday', ..., 'Sunday'])
• data['Week2'] → Y-axis values (sales for Week 2)
• label='Week 2' → Used in the legend to name this line "Week 2".)
5. Find the total sales across all weeks on Friday.
(Explanation:
• data['Days'] == 'Friday' filters the row where the day is Friday.
• [['Week1', 'Week2', 'Week3']] selects only the weekly sales columns.
• .sum(axis=1) adds up Week1 + Week2 + Week3 for Friday only.
• It returns a single value: total Friday sales across all 3 weeks.
• .iloc[0] turns that single-row DataFrame into a Pandas Series:
• friday_sales → The data values to be plotted (Week1, Week2, Week3 sales).
• labels=friday_sales.index → Sets labels as ['Week1', 'Week2', 'Week3'].
• autopct='%1.1f%%' → Shows each slice’s percentage with 1 decimal (e.g., "32.7%").
• colors=['red', 'blue', 'green'] → Assigns specific colors to each week for clarity.)
6. Identify the day with the lowest sales in Week 1.
(Explanation:
• data['Week1'].idxmin() → Finds the index of the lowest value in the Week1 column.
• data['Days'][...] → Uses that index to retrieve the day name (e.g., "Monday")
• colors = ['red' if val == min_value else 'gray' for val in data['Week1']]
If the sale equals the minimum value, color it red,Otherwise, color it gray.)
7. Create a bar chart showing average sales per week.