饮歌长啸
如果你想先对['cluster', 'org']组合采取均值,然后再对cluster群体采取均值In [59]: (df.groupby(['cluster', 'org'], as_index=False).mean() .groupby('cluster')['time'].mean())Out[59]:cluster1 152 543 6Name: time, dtype: int64如果你cluster不仅仅意味着价值观,那么你可以In [58]: df.groupby(['cluster']).mean()Out[58]: timecluster1 12.3333332 54.0000003 6.000000你可以groupby上['cluster', 'org']再取mean()In [57]: df.groupby(['cluster', 'org']).mean()Out[57]: timecluster org1 a 438886 c 232 d 9874 h 343 w 6