python - reshape a pandas dataframe - Stack Overflow
https://stackoverflow.com/questions/42928911The pd.wide_to_long function is built almost exactly for this situation, where you have many of the same variable prefixes that end in a different digit suffix. The only difference here is that your first set of variables don't have a suffix, so you will need to rename your columns first. The only issue with pd.wide_to_long is that it must have an identification variable, i, unlike melt.