title: Reversing 'one-hot' encoding in Pandas
body: <p>I want to go from this data frame which is basically one hot encoded.</p>
  <pre><code> In [2]: pd.DataFrame({&quot;monkey&quot;:[0,1,0],&quot;rabbit&quot;:[1,0,0],&quot;fox&quot;:[0,0,1]})
  
      Out[2]:
         fox  monkey  rabbit
      0    0       0       1
      1    0       1       0
      2    1       0       0
      3    0       0       0
      4    0       0       0
  </code></pre>
  <p>To this one which is 'reverse' one-hot encoded.</p>
  <pre><code>    In [3]: pd.DataFrame({&quot;animal&quot;:[&quot;monkey&quot;,&quot;rabbit&quot;,&quot;fox&quot;]})
      Out[3]:
         animal
      0  monkey
      1  rabbit
      2     fox
  </code></pre>
  <p>I imagine there's some sort of clever use of apply or zip to do thins but I'm not sure how... Can anyone help?</p>
  <p>I've not had much success using indexing etc to try to solve this problem.</p>