'Python Reorganize dataframe

I have this following dataframe that I want to transform to reorganize data:

DateTime_Equip1_TEMP  Equip1_TEMP  DateTime_Equip2_TEMP Equip2_TEMP
01/01/2022 15:00        37         01/01/2022 15:05      34.5
01/01/2022 15:05        36         01/01/2022 15:10      34.5
01/01/2022 15:10        37         01/01/2022 15:15      34.5

My goal is to transform my dataframe like this:

DateTime          Equip   TEMP
01/01/2022 15:00  Equip1  37
01/01/2022 15:05  Equip1  36
01/01/2022 15:10  Equip1  37
01/01/2022 15:05  Equip2  34.5
01/01/2022 15:10  Equip2  34.5
01/01/2022 15:15  Equip2  34.5

The parameter DateTime can be different in a same row and I can have until 48 equip.

I found this post (Python Pandas, transform dataframe) and try to use melt() function but it was not really succesfull.. I don't if there is a simple way to do that or not. Thanks for your help. Regards



Sources

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

Source: Stack Overflow

Solution Source