Skip to content
Advertisement

Convert subset of columns to rows by combining columns

Pandas 1.1.4

MRE:

JavaScript

Want to make it into

JavaScript

I can do it, but want to explore more (clean) options.

My sol’tn

JavaScript

But code is dirty.

Advertisement

Answer

This is essentially a reshape operation using stack

JavaScript

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement