zoukankan      html  css  js  c++  java
  • pd.pivot_table聚合计算注意事项

    参数 类型 说明
    data DataFrame pd.pivot_table使用,设定需要操作的 DataFrame
    values column

    被计算的数据项

    可选项

    设定需要被聚合操作的列

    index

    array

    column

    grouper

    list of the previous

    行分组键

    用于分组的列名或其他分组键,作为结果DataFrame的行索引

    Keys to group by on the pivot table index

    columns

    array

    column

    grouper

    list of the previous

    列分组键

    用于分组的列名或其他分组键,作为结果DataFrame的列索引

    Keys to group by on the pivot table column

    aggfunc

    dict 

    function

    list of functions

    numpy.mean 默认值

    聚合函数或函数列表

    如果aggfunc中出现list [ ],则在结果DataFrame中,list 内的函数名称肯定会出现在 columns中

    • aggfunc = np.sum
    • ☑ aggfunc = [ np.sum ]
    • aggfunc = [ np.sum,np.mean ] 
    • aggfunc = { 'Price':np.sum } 
    • aggfunc = { 'Price':[np.sum] } 
    • aggfunc = { 'Price':np.sum,'Quantity':len }
    • aggfunc = { 'Price':[np.sum],'Quantity':len }
    • aggfunc = { 'Price':[np.sum,np.mean],'Quantity':len }
    • ☑ 出现 ☒ 不出现
  • 相关阅读:
    9.过滤器的使用
    8.公共组件
    7.Props向子组件传递数据
    6.组件
    5.指令系统-事件
    4.指令系统
    SpringCloud入门
    springcloud注解
    was unable to refresh its cache! status = Cannot execute request on any known server
    集成第三方框架,报错NoSuchFieldError:logger
  • 原文地址:https://www.cnblogs.com/shida-liu/p/13503550.html
Copyright © 2011-2022 走看看