PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Data Manipulation (SQL/Python)/Wayfair

Clean scores and return top 5 students

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in data cleaning and transformation for Data Science, focusing on handling missing values, median imputation, and ranking/sorting logic using SQL or Python (Pandas).

  • easy
  • Wayfair
  • Data Manipulation (SQL/Python)
  • Data Scientist

Clean scores and return top 5 students

Company: Wayfair

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Take-home Project

Implement a Python function to clean and rank student scores. You are given a table (or DataFrame) `students` with schema: | column | type | notes | |---|---|---| | student_id | int | unique identifier | | math_score | float | may be null | | english_score | float | may be null | | physics_score | float | may be null | ### Task Write a function (e.g., `select_top_students(students_df) -> pd.DataFrame`) that: 1. **Removes students with at least 2 missing scores** across the three subjects. 2. For remaining students, **fill missing scores with the subject median** (median computed per subject using the remaining students’ non-missing values). 3. **Sort** the remaining students by: - `math_score` descending, then - `physics_score` descending - (optional tie-breaker) `student_id` ascending. 4. **Return the top 5** students as a table with the same columns. ### Notes / edge cases to handle - Missing values may be represented as `None`/`NaN`. - If fewer than 5 students remain, return all remaining. - If a subject median is undefined (e.g., all remaining values are null for that subject), specify and implement a reasonable behavior (e.g., leave as null or raise an error)—state your assumption in comments.

Quick Answer: This question evaluates proficiency in data cleaning and transformation for Data Science, focusing on handling missing values, median imputation, and ranking/sorting logic using SQL or Python (Pandas).

Related Interview Questions

  • Find top buyer in earliest 10-year window - Wayfair (easy)
  • Solve SQL and Python OA tasks - Wayfair (easy)
Wayfair logo
Wayfair
Feb 18, 2026, 1:21 AM
Data Scientist
Take-home Project
Data Manipulation (SQL/Python)
2
0
Loading...

Implement a Python function to clean and rank student scores.

You are given a table (or DataFrame) students with schema:

columntypenotes
student_idintunique identifier
math_scorefloatmay be null
english_scorefloatmay be null
physics_scorefloatmay be null

Task

Write a function (e.g., select_top_students(students_df) -> pd.DataFrame) that:

  1. Removes students with at least 2 missing scores across the three subjects.
  2. For remaining students, fill missing scores with the subject median (median computed per subject using the remaining students’ non-missing values).
  3. Sort the remaining students by:
    • math_score descending, then
    • physics_score descending
    • (optional tie-breaker) student_id ascending.
  4. Return the top 5 students as a table with the same columns.

Notes / edge cases to handle

  • Missing values may be represented as None / NaN .
  • If fewer than 5 students remain, return all remaining.
  • If a subject median is undefined (e.g., all remaining values are null for that subject), specify and implement a reasonable behavior (e.g., leave as null or raise an error)—state your assumption in comments.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More Wayfair•More Data Scientist•Wayfair Data Scientist•Wayfair Data Manipulation (SQL/Python)•Data Scientist Data Manipulation (SQL/Python)
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.