title: Filter | Groupby | Aggregate
body: <p>I am doing some task in pandas python.</p>
  <p>I have a data like this:</p>
  <pre><code>col1  |col2  |col3 |col4 |col5 | col6
  delhi |assam |&quot;f&quot;  |78.3 |87.1 | B2C
  delhi |goa   |&quot;f&quot;  |78.3 |87.1 | B2C
  delhi |goa   |&quot;f&quot;  |78.3 |87.1 | B2C
  delhi |assam |&quot;f&quot;  |78.3 |87.1 | B2C
  up    |assam |&quot;f&quot;  |78.3 |87.1 | B2B
  delhi |assam |&quot;f&quot;  |78.3 |87.1 | B2B
  </code></pre>
  <p>Now I want to filter those rows where col6 is B2C.
  After filtering , I want to groupby col1 and col2 and sum the col4 and col5.</p>
  <p>So Output should be like:</p>
  <pre><code>col1  |col2  |col3 |col4 |col5 | col6
  delhi |assam |&quot;f&quot;  |156.6|174.2| B2C
  delhi |goa   |&quot;f&quot;  |156.6|174.2| B2C
  up    |assam |&quot;f&quot;  |78.3 |87.1 | B2B
  delhi |assam |&quot;f&quot;  |78.3 |87.1 | B2B
  </code></pre>
  <p>The approach I have tried:</p>
  <pre><code>df.loc[df['col6'] == 'B2C'].groupby(['col1', 'col2']).agg({'col4':'sum', 'col5':'sum'})
  </code></pre>
  <p>But I don't know how to append this result with original data frame. Also guide me if I can do something better than this.</p>