Create subtotals for rows in pivot table for different columns

前端 未结 1 1369
陌清茗
陌清茗 2021-01-15 17:03

I am creating a pivot table with Pandas but got stuck at the subtotals for rows within different columns (under the same Values) for a while, I\'ve done some research on sta

相关标签:
1条回答
  • 2021-01-15 17:22

    pivot_table doesn't support it, but you can compute it yourself and concatenate it later:

    tb.groupby(level='Op', axis=1).sum().add_suffix('Total')
    
    Op          Total  ATotal  BTotal
    Tm                               
    07-01-2018    200     100     100
    08-01-2018    400     200     200
    09-01-2018    600     300     300
    All          1200     600     600
    
    0 讨论(0)
提交回复
热议问题