BuildlyBuildly
DashboardExercisesProfileHelp
Data Science/Module 3: Importing & Handling Files/Pivot & Reshape2/3
Exercise·7 min·10 XP

Reshape Long to Wide

Context. A scores table is long — one row per student-subject pair. For a report card you need it wide: one row per student, one column per subject.

Your task. Write to_wide(df) that pivots the long table so each student is a row and each subject is its own column holding the score. Turn the student index back into a regular column.

Example. rows (Alice, math, 90) and (Alice, science, 85) collapse to one Alice row with math and science columns.

Notes. Each student-subject pair appears exactly once. Every student has a score for every subject in the data.

Previous
Reshape Wide to Long
Next
Wanderstay Booking Log Cleanup