2

So, say I have an army of Salvation-Army-style bell-ringing Santas who are collecting money on the streets in the days leading up to Xmas. My data looks like:

   Day     AM/PM  Santa   Donors  Revenue
12/22/2012  AM   Candi     92     $762.56 
12/22/2012  AM   Bronson    3      $13.06 
12/22/2012  PM   Candi     41      $68.97 
12/23/2012  AM   Aloysius  45     $905.53 
12/21/2012  PM   Aloysius  89     $704.80 
12/24/2012  PM   Aloysius  64     $227.87 
12/23/2012  AM   Candi     54     $223.57 
12/23/2012  AM   Bronson   36     $212.99 

...etc.

What's the pandas code to make an equivalent pivot_table to this? (Note 1. the summing of the "AM/PM" field 2. the calculated field "Avg. Donation" and 3. the subtotals.)

enter image description here

(Is it possible I want to use something besides pivot_table?)

Jonathan Harford
  • 361
  • 1
  • 3
  • 9
  • 1
    pandas can do each of these parts individually, sum, mean, groupby, but don't think there is a native way to print like this... – Andy Hayden Jul 31 '13 at 16:16

0 Answers0