Skip to content
Programs · Program 4-15
Q.

(Program 4-15) To keep improving their services, XYZ group of hotels have asked all the three hotels to get feedback form filled by their customers at the time of checkout. After getting ratings on a scale of (1-5) on factors such as Food, Service, Ambience, Activities, Distance from tourist spots they calculate the average rating and store it in a CSV file ("compareresort.csv"). The data are given in Table 4.9.

Table 4.9 -- year-wise average ratings on five parameters:

YearSunny Bunny ResortHappy Lucky ResortBreezy WIndy Resort
20144.7534.5
20152.542
20163.52.53
2017423.5
20181.54.51
This year, to award the best hotel they have decided to analyse the ratings of the past 5 years for each of the hotels. Plot the data using Boxplot.
Punjab PsebTextbookSubjective· 3mImportance★★★★★est
41% · 18/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 →

Box-plot resort ratings with pandas -- no external plotting library needed.

import pandas as pd
import matplotlib.pyplot as plt
data= pd.read_csv('compareresort.csv')
df= pd.DataFrame(data)
df.plot(kind='box',title='Compare Resorts')
plt.xlabel('Resorts')
plt.ylabel('Rating (5 years)')
plt.show()

This chapter never introduces seaborn -- the real technique is the same one-line df.plot(kind='box', ...) used throughout the chapter.

Step by step

  1. pd.read_csv('compareresort.csv') loads Table 4.9 -- one row per year (2014-2018), one column per resort.
  2. df.plot(kind='box', title='Compare Resorts') box-plots each resort's FIVE yearly ratings as its own box -- three boxes side by side, one per resort column.

Reading Table 4.9's own numbers: Sunny Bunny Resort's five ratings (4.75, 2.5, 3.5,

4, 1.5) average to 3.25 and Happy Lucky Resort's (3, 4, 2.5, 2, 4.5) average to

3.2 -- almost tied on the mean -- while Breezy WIndy Resort (4.5, 2, 3, 3.5, 1) …

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.