title: Python PivotTable/Groupby Text Columns
body: <p>I'm trying to broaden my python horizons and learn to do something that is fairly simple to execute in Excel.</p>
  
  <p>I have this data:</p>
  
  <pre><code>Group   Function
  1   A
  1   B
  1   C
  2   A
  2   C
  3   C
  3   A
  3   D
  4   E
  </code></pre>
  
  <p>And I would like to a table that shows the information in this format (accomplished with a pivot table in Excel with Columns: Function, Rows: Group, Values: Count of Group)</p>
  
  <pre><code>      Function
  Group A        B       C    D    E
  1     1        1       1    
  2     1                1
  3     1                1    1
  4                                1
  </code></pre>
  
  <p>I've created a dataframe and added a column as below:</p>
  
  <pre><code>df = pd.read_excel(filepath)
  df['1']=1
  
  print(df.groupby('GROUP'))
  </code></pre>
  
  <p>but:</p>
  
  <p>1) It's not recognizing the Function field because it's dtype: object
  2) It's not really perfomring the function I'm looking for, which makes me think that it's probably not the function I need.  I've also tried to work various iterations of pivot_table but can't seem to get that to work etiher.</p>
  
  <p>Does anyone have any ideas?  Thanks in advance.</p>