title: Forward fill columns if row value is equal to x - Pandas
body: <p>I'm trying to forward fill specific columns but only where a row is equal to a certain value. For instance, using the df below, I want to .ffill() Val1, Val2, Helper where rows in Helper = 'Forward'. Everything else should remain the same.</p>
  
  <pre><code>df = pd.DataFrame({   
          'Col' : ['X',np.nan,np.nan,'Y',np.nan,'Z',np.nan,np.nan,np.nan],  
          'Val1' : ['B',np.nan,np.nan,'A',np.nan,'C',np.nan,np.nan,np.nan],   
          'Val2' : ['A',np.nan,np.nan,'C',np.nan,'C',np.nan,np.nan,np.nan],                 
          'Helper' : ['No',np.nan,np.nan,'Forward',np.nan,'Held',np.nan,np.nan,np.nan],                  
          })
  
  mask = df['Helper'].str.contains('Forward', na = True)
  
  df.loc[mask, 'Val1'] = df['Val1']
  df['Val1'] = df['Val1'].ffill()
  df.loc[mask, 'Val1'] = np.nan
  </code></pre>
  
  <p>Intended Output:</p>
  
  <pre><code>   Col Val1 Val2   Helper
  0    X    B    A       No
  1  NaN  NaN  NaN      NaN
  2  NaN  NaN  NaN      NaN
  3    Y    A    C  Forward
  4  NaN    A    C  Forward
  5    Z    C    C     Held
  6  NaN  NaN  NaN      NaN
  7  NaN  NaN  NaN      NaN
  8  NaN  NaN  NaN      NaN
  </code></pre>