title: Group by a Dictionary in Pandas DataFrame
body: <p>I read data from an excel file, it is like this:</p>
  
  <p><a href="https://i.stack.imgur.com/G5yQZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G5yQZ.jpg" alt="enter image description here"></a></p>
  
  <p>and I want to get the sum of Q1 and Q2 for each employee, so I create a dictionary, and want to group by based on that, </p>
  
  <pre><code>import pandas as pd
  
  mb2 = pd.read_excel('C:\\Users\\IBM_ADMIN\\Desktop\\ml-1m\\工作簿1.xlsx', sheetname='Sheet3')
  mapping = {'Jan':'Q1','Feb':'Q1','Mar':'Q1','Apr':'Q2','May':'Q2','Jun':'Q2'}
  mb2.groupby(by=mapping,axis=1).sum()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/i0zDx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i0zDx.jpg" alt="enter image description here"></a></p>
  
  <p>How to show also the field Name? I try to do like this, but it didn't work:</p>
  
  <pre><code>mb2.groupby(by=(mapping,'Name'),axis=1).sum()
  </code></pre>