title: Replacing values in a Pandas data frame with the order of their columns
body: <p>How can we replace specific values in a data frame such that the replacements are equal to the order of the ith column where those specific values reside? For example I have this DF:</p>
  
  <pre><code>A  B  C
  0  0  1
  1  0  0 
  1  0  0
  0  1  0
  1  0  1
  </code></pre>
  
  <p>Replacing all ones in this data frame with the order of the ith column (1st, 2nd, 3rd, etc) where the 1's reside, so that it loos like this:</p>
  
  <pre><code>A  B  C
  0  0  3
  1  0  0 
  1  0  0
  0  2  0
  1  0  3
  </code></pre>
  
  <p>That is what I thought would work, but it did not:</p>
  
  <pre><code> DF_2= [(0 if i== 0 else j  for i in DF.iloc[:,j]  ) for j in range(DF.shape[1]) ]
  </code></pre>