大熊猫占群总数的百分比
df = pd.DataFrame({'state': ['CA', 'WA', 'CO', 'AZ'] * 3, 'office_id': range(1, 7) * 2, 'sales': [np.random.randint(100000, 999999) for _ in range(12)]})df.groupby(['state', 'office_id']).agg({'sales': 'sum'})
sales state office_id AZ 2 839507 4 373917 6 347225CA 1 798585 3 890850 5 454423CO 1 819975 3 202969 5 614011WA 2 163942 4 369858 6 959285
state
groupby
sales
state
莫回无
相关分类