title: Melting pandas data frame with multiple variable names and multiple value names
body: <p>How can I melt a pandas data frame using multiple variable names and values? I have the following data frame that changes its shape in a for loop. In one of the for loop iterations, it looks like this:</p>
  
  <pre><code>ID  Cat    Class_A   Class_B     Prob_A     Prob_B
  1   Veg      1        2          0.9         0.1
  2   Veg      1        2          0.8         0.2
  3   Meat     1        2          0.6         0.4
  4   Meat     1        2          0.3         0.7
  5   Veg      1        2          0.2         0.8
  </code></pre>
  
  <p>I need to melt it in such a way that it looks like this:</p>
  
  <pre><code>ID  Cat    Class     Prob    
  1   Veg      1       0.9       
  1   Veg      2       0.1
  2   Veg      1       0.8        
  2   Veg      2       0.2
  3   Meat     1       0.6         
  3   Meat     2       0.4
  4   Meat     1       0.3         
  4   Meat     2       0.7
  5   Veg      1       0.2         
  5   Veg      2       0.8
  </code></pre>
  
  <p>During the for loop the data frame will contain different number of classes with their probabilities. That is why I am looking for a general approach that is applicable in all my for loop iterations. I saw this <a href="https://stackoverflow.com/questions/38862832/pandas-melt-several-groups-of-columns-into-multiple-target-columns-by-name">question</a> and <a href="https://stackoverflow.com/questions/32105368/pandas-dataframe-reshaping-stacking-of-multiple-value-variables-into-seperate-co">this</a> but they were not helpful!</p>