← All Python interview questions

Unpivot a wide survey export into tidy rows

MediumPandas — CleaningDeloitteNielsen

The survey tool exports one column per question. Analysis needs tidy long format instead.

Write tidy(df) that melts the q1, q2 and q3 columns into question/score pairs, keeps respondent, drops rows with a missing score, and returns the result sorted by respondent then question with a reset index.