title: Groupby pandas dataframe two columns with same value
body: <p>I want to <code>groupby</code> two column with the same value in 'A' and 'B' and make a <code>cumsum</code> based on which column is located that value.</p>
  <p>Example of grouped dataframe for a values</p>
  <pre><code>   A  B  ValueA  ValueB
  0  b  a       1       3
  1  c  a       2       2
  2  a  b       2       4
  </code></pre>
  <p>Now, if the value is in column 'A' consider ValueA to <code>cumsum</code> if the value is in column 'B' consider ValueB to <code>cumsum</code></p>
  <p>EDIT: I would to perform <code>shift().rolling()</code> just like <code>cumsum</code>, I tried to put it after groupby but result is not correct.</p>
  <p>Code</p>
  <pre><code>from numpy.core.numeric import NaN
  
  df = pd.DataFrame({
      'A' : ['b','c','a','c','a','c','b','c'],
      'B': ['a', 'a', 'b', 'b','c','a','a','b'],
      'ValueA':[1,2,2,1,2,4,7,1],
      'ValueB':[3,2,4,3,1,2,4,5]
  })
  print(df)
  
  df[['sumA','sumB']] = (
      df[['ValueA','ValueB']].stack(dropna=False)
        .groupby(df[['A','B']].stack().tolist())
        .cumsum()
        .unstack()
  )
  print(df)
  
  #groupby(...).shift().rolling(2, min_periods=2).sum()
  
  df['Expected_Shift_RollingA'] = [NaN,NaN,5,NaN,4,2,7,5]
  df['Expected_Shift_RollingB'] = [NaN,NaN,NaN,5,3,4,4,10]
  print(df)
  </code></pre>