gpt4 book ai didi

python - Pandas .agg 函数有哪些?

转载 作者:行者123 更新时间:2023-11-28 18:05:08 26 4
gpt4 key购买 nike

假设我有这样的代码:

meanData = all_data.groupby(['Id'])[features].agg('mean')

这按'Id' 值对数据进行分组,选择所需的特征,并通过计算的'mean' 聚合每个组每组。

来自documentation ,我知道 .agg 的参数可以是一个字符串,它命名将用于聚合数据的函数。

我还发现有效的字符串包括'mean''median''sum''max ''min''std'(标准差)。

但是,我无法在文档中找到这些名称的完整列表。 .agg 还能做什么?

最佳答案

您可以在 GroupBy § Computations / descriptive stats 下的文档中找到完整列表.

List目前包含了很多聚合函数:

所有,任何,bfill,backfill,count,cumcount,cummax,cummin,cumprod,cumsum,ffill,first,head,last,max,mean,median,min,ngroup,nth,ohlc,pad,prod,rank , pct_change, size, sem, std, sum, var, tail

The following methods are available in both SeriesGroupBy and DataFrameGroupBy objects, but may differ slightly, usually in that the DataFrameGroupBy version usually permits the specification of an axis argument, and often an argument indicating whether to restrict application to columns of a specific data type.

所有,任何,回填,bfill,corr,计数,cov,cumcount,cummax,cummin,cumprod,cumsum,描述,diff,ffill,fillna,过滤器,hist,idxmax,idxmin,mad,nunique,pad,pct_change , plot, quantile, rank, resample, sample, shift, size, skew, take, tshift, value_counts

复制代码

The following methods are available only for SeriesGroupBy objects.

hist, nlargest, nsmallest, unique, is_monotonic_increasing, is_monotonic_decreasing

The following methods are available only for DataFrameGroupBy objects.

corrwith,箱线图

关于python - Pandas .agg 函数有哪些?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53943319/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com