title: How to replace a value in a pandas dataframe with column name based on a condition?
body: <p>I have a dataframe that looks something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/QG7VO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QG7VO.png" alt="enter image description here"></a></p>
  
  <p>I want to replace all 1's in the range A:D with the name of the column, so that the final result should resemble:</p>
  
  <p><a href="https://i.stack.imgur.com/8THwx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8THwx.png" alt="enter image description here"></a></p>
  
  <p>How can I do that?</p>
  
  <p>You can recreate my dataframe with this:</p>
  
  <pre><code>dfz = pd.DataFrame({'A' : [1,0,0,1,0,0],
                      'B' : [1,0,0,1,0,1],
                      'C' : [1,0,0,1,3,1],
                      'D' : [1,0,0,1,0,0],
                      'E' : [22.0,15.0,None,10.,None,557.0]})
  </code></pre>