Data Cleaning Exercises

Task: the rules
Input
  survey(respondent, q1, q2, q3) — text. respondent is unique. Each answer is a whole number 1–5 or missing.

Rules
  Reshape to one row per respondent and question: question is the column name (q1, q2 or q3), score is the
  answer as a whole number.
  An unanswered question produces no row. It is not a score of 0 and it is not an error.

Output (row order does not matter)
  clean(respondent text, question text, score int64)

Tab inserts spaces. Press Escape, then Tab, to move focus out of the editor.

Input: survey, rows 1 to 6 of 6
#respondentstringq1stringq2stringq3string
1r34421missing
2r390missingmissingmissing
3r34253missing
4r340missing12
5r3415missing1
6r343324

Run preview · in your browser, not a grade

Loading the preview runtime…

Check answer · graded on an isolated server, including hidden datasets

Your code runs in a locked-down machine with no network, on the visible data and on hidden datasets that follow the same rules.

Learn from this exercise

A worked solution becomes available after your first check or once you've used every hint.

AI tutor · may be wrong; the grader decides

SQL · DuckDB 1.5.1Preview runtime loadingNot saved yet · sign in to save to your account