title: apply my function if...else statement with condition
body: <p>My input:</p>
  <pre><code>    frame   user1   user2   sum_result
  0   0          0    0        0     
  1   1          0    0        0
  2   2          0    1        1
  3   3          1    1        2
  4   4          1    0        1
  5   5          0    0        0
  </code></pre>
  <p>I want apply <code>my_func</code> with condition to `sum_result'.</p>
  <p>That my condition: if <code>sum_result</code>=2 return <code>'ICV'</code>, if <code>sum_result</code>=1 and number of <code>frame</code> less(&lt;=10) or equal number of <code>frame</code> with result 2  than return <code>'ReviewNG'</code> (number of <code>frame</code> within <code>sum_result</code>=2 minus number of <code>frame</code> within <code>sum_result</code>=1, so result less or equal 10), if <code>sum_result</code>=0 return 'Other'.</p>
  <p>For example output that I expected:</p>
  <pre><code>    frame   user1   user2   sum_result Result
  0   0          0    0        0          Other
  1   1          0    0        0          Other
  2   2          0    1        1          ReviewNG
  3   3          1    1        2          ICV
  4   4          1    0        1          ReviewNG
  5   5          0    0        0          Other
  </code></pre>
  <p>That my code:</p>
  <pre><code>def result_func(row):
  for i in range(0,len(df)):
      if row==2:        
          return('|ICV')
      elif row==1 &amp; (df['frame'][i]-df.loc[df['sum_result']==2,'frame'].iloc[0]&lt;=10 | df['frame'][i]-df.loc[df['sum_result']==2,'frame'].iloc[-1]&lt;=10):
          return('ReviewNG-ICV')
      elif row==0:
          return('Other')
      else:
          return &quot;&quot;
  </code></pre>
  <p>and applying on df:</p>
  <pre><code>df['result']=df['sum_result'].apply(lambda row: result_func(row))  
  </code></pre>
  <p>But I have Error:</p>
  <blockquote>
  <p>IndexError: single positional indexer is out-of-bounds</p>
  </blockquote>
  <p>I understand if in my df no condition to <code>sum_result</code>=2 it make error. How I can fix my function?</p>