title: Pandas column name of the max cell value
body: <p>I have a df which has some codes in the leftmost column and a forward profile in the other columns (df1 below)</p>
  
  <p>df1:</p>
  
  <pre><code>   code        tp1        tp2        tp3        tp4        tp5       tp6  \
  0  1111   0.000000   0.000000   0.018714   0.127218   0.070055  0.084065   
  1   222   0.000000   0.000000   0.000418   0.000000   0.017540  0.003015   
  2   333   1.146815   1.305678   0.384918   0.688284   0.000000  0.000000   
  3   444   0.000000   0.000000   1.838797   0.000000   0.000000  0.000000   
  4   555  27.190002  27.134837  24.137560  17.739465  11.990806  8.631395   
  5   666   0.000000   0.000000   0.000000   0.000000   0.000000  0.000000   
  
          tp7        tp8        tp9       tp10  
  0  0.019707   0.000000   0.000000   0.000000  
  1  6.594860  10.535905  15.697232  21.035824  
  2  0.000000   0.000000   0.000000   0.000000  
  3  0.000000   0.000000   0.000000   0.000000  
  4  7.476197   6.461532   5.570051   4.730345  
  5  0.000000   0.000068   0.000000   0.000000  
  </code></pre>
  
  <p>I want the output to be a 3 column df (df2 below) which has the column name of the cell (for each code) which has the last number (+ve or -ve) after which there are only 0s. The 2nd Column (<code>tp_with_max_num</code>) will have the column name which has the max such number. </p>
  
  <p>df2:</p>
  
  <pre><code>   code max_tp tp_with_max_num
  0  1111    tp7             tp4
  1   222   tp10            tp10
  2   333    tp4             tp2
  3   444    tp3             tp3
  4   555   tp10             tp1
  5   666    tp8             tp8
  </code></pre>
  
  <p>Using this : <a href="https://stackoverflow.com/questions/34200153/name-of-column-that-contains-the-max-value">name of column, that contains the max value</a>
  i was able to get the 3rd column:</p>
  
  <pre><code>input_df['tp_with_max_num'] = input_df.ix[0:6,1:].apply(lambda x: input_df.columns[1:][x == x.max()][0], axis=1)
  </code></pre>
  
  <p>I am unable to solve for the 2nd column in df2....</p>