我打算在groupby
之后合并Pandas数据帧的列。我寻找我可以使用的选项,但没有一个能满足我的要求。最接近的选项是.agg()
,它对列的值执行操作,但是,我想为每个给定的groupbyed行计算所有features
的统计信息。你知道吗
我在找这样的东西:
dataset.groupby(['company', 'team']).combine(new_cols=['features_mean'], to_combine=['feature 1':'feature 2'], funcs=[np.mean], axis=1)
将^{} 与
mean
一起使用:样本:
我意识到我甚至不需要使用
groupby
。我可以简单地使用apply
:This post helped!
但是,由于在implementation中使用了
for
循环,它运行缓慢。你知道吗相关问题 更多 >
编程相关推荐