Using Pandas we can do the following:
A summary of transformations steps can be helpful:
| Step | Operation | Result |
|---|---|---|
| 1 | set_index | Rows get hierarchical keys |
| 2 | stack | Wide → long with 3-level row index |
| 3 | reset + extract | Parse variable names into fields |
| 4 | pivot | Tidy format with metric columns |
| 5 | unstack | Wide format with MultiIndex columns |
In DE_Tools see:
Related terms:
Split-Apply-Combine
