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
接受的字符串列表?你知道吗
我假设它将是^{} 接受的相同字符串(据我所知)
['mean', 'median', 'prod', 'sum', 'std', 'var']
。你知道吗编辑:在阅读熊猫文档时,我发现:
拍摄于from this source。它是在使用
df.prod()
或df.quantile()
的上下文中使用的,但我猜它也可以转换为字符串函数。你知道吗相关问题 更多 >
编程相关推荐