title: Pandas GroupBy using another DataFrame of one-hot encodings/overlapping masks
body: <p>I have two dataframes with observations on rows and features (or group membership) on columns, e.g.:</p>
  
  <pre><code>&gt; data_df
  
       a    b    c
  A    1    2    1
  B    0    1    3
  C    0    0    1
  D    2    1    1
  E    1    1    1
  
  &gt; mask_df
  
      g1   g2
  A    0    1
  B    1    0
  C    1    0
  D    1    0
  E    0    1
  </code></pre>
  
  <p>I want to group and aggregate (by sum) the values in the first dataframe (<code>data_df</code>) conditional on the binary values (masks) in the second dataframe (<code>mask_df</code>). The result should be the following (groups x features):</p>
  
  <pre><code>&gt; aggr_df
  
       a    b    c
  g1   2    2    5
  g2   2    3    2
  </code></pre>
  
  <p>Is there a way in pandas to group the first dataframe (<code>data_df</code>) using the masks contained in a second dataframe (<code>mask_df</code>) in a single command? </p>