title: pandas dataframe apply using additional arguments
body: <p>with below example:</p>
  
  <pre><code>df = pd.DataFrame({'signal':[1,0,0,1,0,0,0,0,1,0,0,1,0,0],'product':['A','A','A','A','A','A','A','B','B','B','B','B','B','B'],'price':[1,2,3,4,5,6,7,1,2,3,4,5,6,7],'price2':[1,2,1,2,1,2,1,2,1,2,1,2,1,2]})
  </code></pre>
  
  <p>I have a function "fill_price" to create a new column 'Price_B' based on 'signal' and 'price'. For every 'product' subgroup, Price_B equals to Price if 'signal' is 1. Price_B equals previous row's Price_B if signal is 0. If the subgroup starts with a 0 'signal', then 'price_B' will be kept at 0 until 'signal' turns 1.</p>
  
  <p>Currently I have:</p>
  
  <pre><code>def fill_price(df, signal,price_A):
  p = df[price_A].where(df[signal] == 1)
  return p.ffill().fillna(0).astype(df[price_A].dtype)
  </code></pre>
  
  <p>this is then applied using:</p>
  
  <pre><code>df['Price_B'] = fill_price(df,'signal','price')
  </code></pre>
  
  <p>However,  I want to use df.groupby('product').apply() to apply this fill_price function to two subsets of 'product' columns separately, and also apply it to both'price' and 'price2' columns. Could someone help with that?</p>
  
  <p>I basically want to do:</p>
  
  <pre><code>df.groupby('product',groupby_keys=False).apply(fill_price, 'signal','price2')
  </code></pre>