zoukankan      html  css  js  c++  java
  • pandas.pivot_table

    pandas.pivot_table — pandas 1.3.5 documentation (pydata.org)

    pandas.pivot_table(datavalues=Noneindex=Nonecolumns=Noneaggfunc='mean'fill_value=Nonemargins=Falsedropna=Truemargins_name='All'observed=Falsesort=True)[source]

    Create a spreadsheet-style pivot table as a DataFrame.

    The levels in the pivot table will be stored in MultiIndex objects (hierarchical indexes) on the index and columns of the result DataFrame.

    Parameters
    dataDataFrame
    valuescolumn to aggregate, optional
    indexcolumn, Grouper, array, or list of the previous

    If an array is passed, it must be the same length as the data. The list can contain any of the other types (except list). Keys to group by on the pivot table index. If an array is passed, it is being used as the same manner as column values.

    columnscolumn, Grouper, array, or list of the previous

    If an array is passed, it must be the same length as the data. The list can contain any of the other types (except list). Keys to group by on the pivot table column. If an array is passed, it is being used as the same manner as column values.

    aggfuncfunction, list of functions, dict, default numpy.mean

    If list of functions passed, the resulting pivot table will have hierarchical columns whose top level are the function names (inferred from the function objects themselves) If dict is passed, the key is column to aggregate and value is function or list of functions.

    fill_valuescalar, default None

    Value to replace missing values with (in the resulting pivot table, after aggregation).

    marginsbool, default False

    Add all row / columns (e.g. for subtotal / grand totals).

    dropnabool, default True

    Do not include columns whose entries are all NaN.

    margins_namestr, default ‘All’

    Name of the row / column that will contain the totals when margins is True.

    observedbool, default False

    This only applies if any of the groupers are Categoricals. If True: only show observed values for categorical groupers. If False: show all values for categorical groupers.

    Changed in version 0.25.0.

    sortbool, default True

    Specifies if the result should be sorted.

    New in version 1.3.0.

    Returns
    DataFrame

    An Excel style pivot table.

     

  • 相关阅读:
    LETTers比赛第十二场解题报告
    LETTers练习赛第十场 第四题
    LETTers练习赛第十场 第二题
    LETTers练习赛第十场 第一题
    LETTers练习赛十一场解题报告
    RedHat Enterprise Linux 基本网络配置
    c# 连接MySQL中文乱码问题的解决方法
    [原]iBatis.Net(C#)系列一:简介及运行环境
    ArcGIS 9.3 sp1 下载更新
    [原]iBatis.Net(C#)系列二:SQL数据映射
  • 原文地址:https://www.cnblogs.com/bravesunforever/p/15758792.html
Copyright © 2011-2022 走看看