我试图用一些基本的摘要函数在pandas dataframe中聚合一些数据,但是我需要一些这些摘要函数的函数
我目前正在做的是:
df_summary = df.groupby(['list', 'of', 'column', 'names'])['column to summarize'].agg(['sum', 'mean', 'some other functions'])
df_summary["other_summary1"] = df_summary["mean"] * constant1 + constant2
df_summary["other_summary2"] = math.log(df_summary["other_summary1"])
我的直觉告诉我,这不是惯用的方法,而且肯定有一种方法可以在.agg()
中转换函数。有吗
目前没有回答
相关问题 更多 >
编程相关推荐