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.

 

 

 

 

 

 

 

 

 

 

推荐这些技术文章:

SQL-DML-数据库操纵语言

 
 SELECT column_name FROM table_name
 
BEGIN TRANSACTION;
INSERT INTO  table_name VALUES(value1,value2,...) ;
COMMIT;
 
UPDATE table_name
SET column&nbs...

pandas函数之pivot、pivot_table和crosstab

1、pivot方法
  pandas.pivot(data, index=None, columns=None, values=None)
  (1)参数
    data:DataFrame
    index:str or object or a list of str, optional。用于创建新DataFrame索引名称。 如果没有,则使用现有的索引。
 ...

【Pandas】1.数据读取

Pandas 1.数据读取
进行数据分析最麻烦的就是数据获取,然后一旦获得了数据,我们就可以很愉快的开始玩耍这些数据。Pandas的IO tools提供了很多的数据源的类型,但实际上,对于我这个初学者可能用的最多可能就是excel文件了。这里就需要用到pandas.read_excel()函数。
1.1 pandas.read_excel()
我们先看下read_excel()的代码:
pa...

文章标题:pandas.pivot_table
文章链接:https://www.dianjilingqu.com/3243.html
本文章来源于网络,版权归原作者所有,如果本站文章侵犯了您的权益,请联系我们删除,联系邮箱:saisai#email.cn,感谢支持理解。
THE END
< <上一篇
下一篇>>