title: Pandas: assigning columns with multiple conditions and date thresholds
body: <p>Edited:</p>
  
  <p>I have a financial portfolio in a pandas dataframe df, where the index is the date and I have multiple financial stocks per date.</p>
  
  <p>Eg dataframe:</p>
  
  <pre><code>Date    Stock   Weight  Percentile  Final weight
  1/1/2000    Apple   0.010   0.75    0.010
  1/1/2000    IBM    0.011    0.4     0
  1/1/2000    Google  0.012   0.45    0
  1/1/2000    Nokia   0.022   0.81    0.022
  2/1/2000    Apple   0.014   0.56    0
  2/1/2000    Google  0.015   0.45    0
  2/1/2000    Nokia   0.016   0.55    0
  3/1/2000    Apple   0.020   0.52    0
  3/1/2000    Google  0.030   0.51    0
  3/1/2000    Nokia   0.040   0.47    0
  </code></pre>
  
  <p>I created <code>Final_weight</code> by doing assigning values of <code>Weight</code> whenever <code>Percentile</code> is greater than <code>0.7</code></p>
  
  <p>Now I want this to be a bit more sophisticated, I still want <code>Weight</code> to be assigned to <code>Final_weight</code> when <code>Percentile is &gt; 0.7</code>, however after this date (at any point in the future), rather than become 0 when a stocks <code>Percentile</code> is not <code>&gt;0.7</code>, we would still get a weight as long as the Stocks <code>Percentile</code> is above <code>0.5</code> (ie holding the position for longer than just one day).</p>
  
  <p>Then if the stock goes below <code>0.5</code> (in the near future) then <code>Final_weight would become 0</code>.</p>
  
  <p>Eg modified dataframe from above:</p>
  
  <pre><code>Date    Stock   Weight  Percentile  Final weight
  1/1/2000    Apple   0.010   0.75    0.010
  1/1/2000    IBM     0.011   0.4     0
  1/1/2000    Google  0.012   0.45    0
  1/1/2000    Nokia   0.022   0.81    0.022
  2/1/2000    Apple   0.014   0.56    0.014
  2/1/2000    Google  0.015   0.45    0
  2/1/2000    Nokia   0.016   0.55    0.016
  3/1/2000    Apple   0.020   0.52    0.020
  3/1/2000    Google  0.030   0.51    0
  3/1/2000    Nokia   0.040   0.47    0
  </code></pre>
  
  <p>Everyday the portfolios are different not always have the same stock from the day before.</p>