…
…
Clean a dirty online survey; explore the scores, the waiting time, and the suggestion texts to find the source of the dissatisfaction.
The new operator of the campus dining hall ran a satisfaction survey with the student council from October 5 to 16, 2026. The survey was collected with an online form and the results were exported as they are: some students sent the form twice, department names were typed by hand and appear in dozens of different forms, and for the spending question some wrote "8" and some wrote "$8". The operator wants an answer to a single question from you: Why are students not satisfied with the dining hall?
Data: dining_survey_raw.csv, where each row is one answer.
| Column | Description |
|---|---|
timestamp | The moment the form was submitted |
department, year | The student's department (typed by hand) and year |
days_per_week | How many days a week the student eats at the dining hall (0-5) |
meal_spend | Average spending on one meal (in dollars, as text) |
taste, portion, cleanliness, price, variety | Scores from 1 to 5 (5 is best; price is how affordable the prices are) |
wait_min | Waiting time in the line (minutes; optional question) |
overall | Overall satisfaction (1-5) |
suggestion | Free-text suggestion (optional) |
Lessons used: DataFrame and selection (5-8), grouping (9-10), data quality, missing values, and consistency (12-14), grouping with pd.cut (16), central tendency and spread (17-18), charts (20-21).
Each cell rebuilds the clean table from the raw table; no matter how many times you run a cell, you get the same result.
What you'll do
dining_survey_raw.csvDownload file
Reading file…
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
Before we start cleaning, we look at the size of the raw table, the column types, the missing values, and the duplicate rows. meal_spend should be a number: what type is it read as? Why does wait_min have decimals?
Read the file with pd.read_csv and name it raw.
This step's code cell is for members.Sign up free
Forms that were submitted twice are exactly identical rows; drop_duplicates() deletes them. The department of the three answers that were sent to try out the form is written Test.
To standardize the department names, first strip the spaces, remove the invisible zero-width space (U+200B) that some values carry from copy and paste, and lowercase the text; then match every spelling to the right name with the fix dictionary. Exactly five departments should remain. The dictionary comes last because a typo such as buisness cannot be fixed by case or spaces.
This step's code cell is for members.
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
The meal_spend column has three formats: 7.5, $8, and 8,05, where the last one uses a decimal comma. First remove the $ sign, then change the decimal comma to a decimal point and convert the result to numbers with pd.to_numeric. Write the result to a new spend column; do not change the raw column.
Waiting time was an optional question; we will not fill in the empty ones, we will only note how many there are.
This step's code cell is for members.Sign up free
Calculate the mean score of the five topics, sort them from smallest to largest, and show them in a horizontal bar chart. Since the score scale is 1 to 5, fix the axis from 0 to 5; this way the differences are not exaggerated.
Also look at the mean and median of overall satisfaction.
This step's code cell is for members.Sign up free
Split the waiting time into five groups with pd.cut and calculate the number of answers and the mean overall satisfaction in each group. pd.cut creates a categorical column; observed=True removes the groups that have no answers from the table.
Then look at mean satisfaction by department and by the number of days per week students eat at the dining hall. Which difference is larger: between departments, or between waiting groups?
This step's code cell is for members.Sign up free
More than half of the answers have a free-text suggestion. You can lowercase the texts and search them for keywords to count how often each theme appears. Inside str.contains, the | sign means "or": "price|expensive" finds the texts that contain either word.
In the last line, write the findings in one sentence: the most common complaint and the satisfaction of students who waited more than 15 minutes.
This step's code cell is for members.Sign up free