简体   繁体   中英

Python Pandas join aggregated tables

I have a data frame with two columns: product_id and rating. I'm trying to join two tables. One obtained from

a = data.groupby('product_id').count()

The other one

b = data.groupby('product_id').mean()

I'd like to have a table that has on its columns the

product_id  count   mean

尝试:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM