title: How to insert value in column if condition is true using Pandas (Python)
body: <p>I have the following dataset and I am trying to create a condition, where if the value in the Percentage cell is positive, I want the match cell to show the subsequent Percentage value eg (i+1). However, I wanted to ask how would I be able to perform this operation without using a loop. For example, in row 0 and Match, it would display the value -0.34.</p>
  
  <pre><code>        User Percent      Match 
  0          A    0.87        NaN   
  1          A   -0.34        NaN    
  2          A    0.71        NaN    
  3          A   -0.58        NaN    
  4          B   -1.67        NaN  
  5          B   -0.44        NaN  
  6          B   -0.72        NaN  
  7          C    0.19        NaN  
  8          C    0.39        NaN  
  9          C   -0.28        NaN  
  10         C    0.53        NaN
  </code></pre>
  
  <p>Additionally, how would I be able to have a summation of the subsequent two value proceeding a positive number in the Percent cell. I have the following code, but I am making an error in indexing the row location.</p>
  
  <pre><code>df1.ix[df1.Percent &gt;=0, ['Match']] = df1.iloc[:1]['Match']; df1
  </code></pre>