Pandas hierarchical dataframe
Assuming there is a typo in the Text column, text <-> text1?I`ll go from your first DataFrame.
In [11]: dfOut[11]: Form nr Element Type Test Options0 1 Name1 select text1 op11 1 Name1 select text op22 1 Name1 select text op33 1 Name2 input text2 NaN4 2 Name1 input text2 NaNIn [12]: df.set_index(['Form', 'nr Element', 'Type', 'Test'])Out[12]: OptionsForm nr Element Type Test 1 Name1 select text1 op1 text op2 text op3 Name2 input text2 NaN2 Name1 input text2 NaN