title: Python - Fetching either max or min of two colums based on value in another column?
body: <p>Suppose have dataframe with following data  </p>
  
  <pre><code>key score1 score2 count
  1    0.87   0.13   0
  2    0.67   0.33   1
  3    0.46   0.54   1
  4    0.28   0.72   0
  5    0.41   0.59   1
  </code></pre>
  
  <p>what is the shortest way of finding min[score1, score2] if count == 0 or max[score1, score2] when count > 0?</p>
  
  <p>present solution have is  </p>
  
  <pre><code>data['mini']=data[[score1, score2]].min(axis=1)
  data['maxi']=data[[score1, score2]].max(axis=1)
  data['fin_score']= data['mini'].where(data['count']==0, data['maxi'])
  </code></pre>
  
  <p>is there way it could be made more crisp (in 1/2 commands), like in excel this would be as below and then just drag formula across all rows   </p>
  
  <pre><code>=IF(count&gt;0,MAX(B2:C2),MIN(B2:C2))
  </code></pre>
  
  <p>result would like this  </p>
  
  <pre><code>key score1 score2 count fin_score
  1    0.87   0.13   0       0.13
  2    0.67   0.33   1       0.67
  3    0.46   0.54   1       0.54
  4    0.28   0.72   0       0.28
  5    0.41   0.59   1       0.59
  </code></pre>