python - How do I do Excel-style "Calculated fields" (including subtotals) in a pandas pivot_table? -


so, have army of salvation-army-style bell-ringing santas collecting money on streets in days leading xmas. data looks like:

   day     am/pm  santa   donors  revenue 12/22/2012    candi     92     $762.56  12/22/2012    bronson    3      $13.06  12/22/2012  pm   candi     41      $68.97  12/23/2012    aloysius  45     $905.53  12/21/2012  pm   aloysius  89     $704.80  12/24/2012  pm   aloysius  64     $227.87  12/23/2012    candi     54     $223.57  12/23/2012    bronson   36     $212.99  

...etc.

what's pandas code make equivalent pivot_table this? (note 1. summing of "am/pm" field 2. calculated field "avg. donation" , 3. subtotals.)

enter image description here

(is possible want use besides pivot_table?)


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -