title: How to multiply row values in two columns of a dataframe if the result per row is less than x?
body: <p>I want to multiply two independent columns with each other until their product is bigger than x.</p>
  <pre><code>d = {
      'name': ['A','B','C','D','E'],
      'i1': [1,2,3,5,1],
      'i2': [2,2,2,6,8],
      'result': [2,4,6,30,8]
  }
  
  df = pd.DataFrame(d)
  
    name  i1  i2  result
  0    A   1   2       2
  1    B   2   2       4
  2    C   3   2       6
  3    D   5   6      30
  4    E   1   8       8
  </code></pre>
  <p>I want the loop being repeated as long as the result is less than x.</p>
  <pre><code>for _index, row in df.iterrows():
      while row['result'] &lt; 10:
          row['i1'] = row['i1'] * 2
          row['i2'] = row['i2'] * 2
          row['result'] = row['i1'] * row['i2']
      else:
          pass
  </code></pre>
  <p>I don't receive any error, but the df stays untouched. Could you please tell me what I'm doing wrong and what's the best way to solve this?</p>
  <p><strong>First solution</strong></p>
  <pre><code>for index, row in df.iterrows():
      while df.loc[index, 'result'] &lt; 10:
          df.loc[index, 'i1'] = df.loc[index, 'i1'] * 2
          df.loc[index, 'i2'] = df.loc[index, 'i2'] * 2
          df.loc[index, 'result'] = df.loc[index, 'i1'] * df.loc[index, 'i2']
      else:
          pass
  
    name  i1  i2  result
  0    A   4   8      32
  1    B   4   4      16
  2    C   6   4      24
  3    D   5   6      30
  4    E   2  16      32
  </code></pre>
  <p><strong>New problem</strong></p>
  <p>The steps into the direction of my target are too huge. A better solution might be to store the original values per row and add them too the current values within the loop (I need them to stay Integers). This is what I tried:</p>
  <pre><code>for index, row in df.iterrows():
  
      i1 = df.loc[index, 'i1']
      i2 = df.loc[index, 'i2']
  
      while df.loc[index, 'result'] &lt; 10:
          df.loc[index, 'i1'] = df.loc[index, 'i1'] + i1
          df.loc[index, 'i2'] = df.loc[index, 'i2'] + i2
          df.loc[index, 'result'] = df.loc[index, 'i1'] * df.loc[index, 'i2']
      else:
          pass
  </code></pre>
  <p>But running the loop never ends and I have to break it with CTRL-C.</p>