什么是内置的方法DataFrameGroupBy.transform?

2024-04-26 21:10:20 发布

您现在位置:Python中文网/ 问答频道 /正文

DataFrameGroupBy对象由DataFrame.groupby输出并具有方法transform。根据交互式文档(help(pd.core.groupby.DataFrameGroupBy.transform)),此方法将应用于每个组的函数作为参数。你知道吗

但是user guide提到字符串也可以作为“内置方法”的快捷方式作为输入:

Alternatively, the built-in methods could be used to produce the same outputs.

In [99]: max = ts.groupby(lambda x: x.year).transform('max')

如何找到将被transform接受的字符串列表?你知道吗


Tags: the对象方法函数字符串文档coredataframe
1条回答
网友
1楼 · 发布于 2024-04-26 21:10:20

我假设它将是^{}接受的相同字符串(据我所知)['mean', 'median', 'prod', 'sum', 'std', 'var']。你知道吗

编辑:在阅读熊猫文档时,我发现:

Here is a quick reference summary table of common functions. Each also takes an optional level parameter which applies only if the object has a hierarchical index. enter image description here

拍摄于from this source。它是在使用df.prod()df.quantile()的上下文中使用的,但我猜它也可以转换为字符串函数。你知道吗

相关问题 更多 >