I have a wide dataframe in Python Pandas like this:
date S_load A_LOAD B_LOAD A_GEN B_GEN D_1 E_1 F_2 G_2 H_3 I_3 J_4 K_4 L_5 M_5 N_6 O_6
2012-1-1 100.0 25.0 75.0 30.0 78.0 2.0 9.0 3.0 3.0 20.0 15.0 17.0 33.0 20.0 7.0 2.0 2.0
2012-2-1 105.0 24.0 72.0 32.0 80.0 2.0 19.0 8.0 0.0 21.0 19.0 17.0 30.0 10.0 9.0 2.0 2.0
-----------------------------------------------------------------------------------------------
2020-12-31 20.0 24.0 72.0 32.0 80.0 2.0 19.0 8.0 0.0 21.0 19.0 17.0 30.0 10.0 9.0 2.0 2.0
I want reshape the dataframe from wide to long format using wide to long pandas to the following:
date S_load A_LOAD B_LOAD A_GEN B_GEN zone Substation Value
2012-1-1 100.0 25.0 75.0 30.0 78.0 one D 2.0
2012-1-1 100.0 25.0 75.0 30.0 78.0 one E 9.0
2012-1-1 100.0 25.0 75.0 30.0 78.0 two F 3.0
2012-1-1 100.0 25.0 75.0 30.0 78.0 two G 3.0
2012-1-1 100.0 25.0 75.0 30.0 78.0 three H 20.0
2012-1-1 100.0 25.0 75.0 30.0 78.0 three I 15.0
2012-1-1 100.0 25.0 75.0 30.0 78.0 four J 17.0
2012-1-1 100.0 25.0 75.0 30.0 78.0 four K 33.0
2012-1-1 100.0 25.0 75.0 30.0 78.0 five L 20.0
2012-1-1 100.0 25.0 75.0 30.0 78.0 five M 7.0
2012-1-1 100.0 25.0 75.0 30.0 78.0 six N 2.0
2012-1-1 100.0 25.0 75.0 30.0 78.0 six O 2.0
---------------------------------------------------------------------
up to 2020-12-31
Any help?