Python连接聚合表

Python连接聚合表,python,pandas,Python,Pandas,我有一个包含两列的数据框:product_id和rating。我想把两张桌子连接起来。从……获得的 a = data.groupby('product_id').count() 另一个 b = data.groupby('product_id').mean() 我想要一个列上有 product_id count mean 尝试: data.groupby('product_id').agg(['mean', 'count'])

我有一个包含两列的数据框:product_id和rating。我想把两张桌子连接起来。从……获得的

a = data.groupby('product_id').count()
另一个

b = data.groupby('product_id').mean()
我想要一个列上有

product_id  count   mean
尝试:

data.groupby('product_id').agg(['mean', 'count'])