How does a pivot table aggregate repeated store sales?

pandas.pivot_table groups observations by row and column keys, then applies an aggregation function. Its default aggregation is the mean.

pivot_table in practice

A store records revenues of 20 and 40 on Monday. Summing yields daily revenue of 60, while the default gives 30. Decide whether an absent combination actually means zero revenue.

中文

透视表怎样合计重复的门店销售记录?

pandas.pivot_table 先按行列键分组,再将每组观测交给聚合函数。默认聚合为均值。

pivot_table 应用实例

某门店周一有两笔收入 20 和 40。用 aggfunc='sum' 得到当日收入 60,使用默认值则为 30。空组合与真实零收入应按业务定义区分。

References / 参考来源

Keep reading / 继续阅读