Multiple Aggregate Function Over A Pivot Table
how to get the multiple aggregate function over a pivot table of all the columns not by individual columns over the pivot table. here is my pivot table kpi_date 2019-01-01 20
Solution 1:
Using agg
df.agg(['mean','sum','max'])
2019-01-01 2019-01-02 2019-01-16 2019-01-17
mean 8613.473684 8018.263158 8186.578947 8386.578947
sum 163656.000000 152347.000000 155545.000000 159345.000000
max 43029.000000 40038.000000 37599.000000 39125.000000
If need all values using stack
df.stack().agg(['max','mean','min'])
max 43029.000000
mean 8301.223684
min 1317.000000
dtype: float64
If need all row
df.T.agg(['mean','sum','max'])
Post a Comment for "Multiple Aggregate Function Over A Pivot Table"