且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python Pandas:使用参数将多个函数传递给agg()

更新时间:2022-12-13 14:57:56

好吧,

Well, the docs on aggregate are in fact a bit lacking. There might be a way to handle this with the correct passing of arguments, and you could look into the source code of pandas for that (perhaps I will later).

但是,您可以轻松做到:

However, you could easily do:

df.groupby('A').agg([np.mean, lambda x: np.std(x, ddof=0)])

它也将正常工作.