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 }
    • ☑ 出现 ☒ 不出现
  • 相关阅读:
    CPU飙高,OOM排查?
    反射
    Mybatits
    spring 基础问题
    java中格式化数字0和#区别
    java中File对象的mkdir和mkdirs的区别
    java截取字符串几种方式
    java工厂模式
    Java获取文件路径的几种方式
    jxl生成excel时,增加批注和冻结窗口
  • 原文地址:https://www.cnblogs.com/shida-liu/p/13503550.html
Copyright © 2011-2022 走看看