title: How to return column index for every row where a certain value appears for the first time
body: <p>I have a data frame in pandas, where 1 appears in different columns for every rows. The column where 1 appears for the first time in a row is different for different rows. I need to create an additional column (column index) in which as value I want to return the index number of the column where 1 appears for the first time in that row. </p>
  
  <pre><code>Example dataframe:
  
  IDs     q1    q2    q3    q4    q5    q6    q7    q8
  
  1111    0     0     0      1    0      0     0     1
  
  1122    0     0     1      0    0      1     0     0
  
  the output should like this: 
  
  IDs     q1    q2    q3    q4    q5    q6    q7    q8    column_index
  
  1111    0     0     0      1    0      0     0     1        5
  
  1122    0     0     1      0    0      1     0     0        4 
  </code></pre>
  
  <p>It would be helpful if anyone can provide the code useful in pandas. 
  Thanks in advance.</p>