'Is there a way to unpivot a dynamic amount of columns?

Currently I have a data set that looks something that has a set amount of key identifiers and depending on a specific row of identifiers it may have one set of attributes (3 total) or may have several of the same repeating attribute names with different values. I would like to take the repeating attributes and create a new row, but i'm not getting the melt function to work the way I want it to. here is the code I was trying df1=df.melt(id_vars=['Identifier 1','Identifier 2','Identifier 3','Identifier 4']) example of current table Example of table melt



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source