title: Subtotal & Grandtotal in Pandas pivots
body: <p><a href="https://i.stack.imgur.com/IyH8r.png" rel="nofollow noreferrer">Data Currently Populated</a></p>
  
  <p><a href="https://i.stack.imgur.com/jlyCt.png" rel="nofollow noreferrer">Data Desired</a></p>
  
  <p>Code snippet used :-</p>
  
  <pre><code>df["Average"] = df["Average"].astype("category")
  
  writer = pd.ExcelWriter('New.xlsx', engine='xlsxwriter')
  
  table1 = pd.pivot_table(df,values=['Average'],index=['Manager','Cost'],aggfunc=[len],fill_value=0)
  
  table2 = pd.pivot_table(df,values=['Average'], index=['Manager','Cost'],aggfunc=[np.sum],fill_value=0)
  
  table = pd.concat((table1, table2), axis=1)
  
  table.to_excel(writer, sheet_name='Sheet2')
  
  table3 = pd.pivot_table(df,values=['Average'], index=['Project','Cost'],aggfunc=[len],fill_value=0)
  
  table4 = pd.pivot_table(df,values=['Average'], index=['Project','Cost'],aggfunc=[np.sum],fill_value=0)
  
  project_table = pd.concat((table3, table4), axis=1)
  
  project_table.to_excel(writer, sheet_name='Sheet3')
  </code></pre>
  
  <p>Please help me achieve the desired outcome?</p>