groupby语法:
grouby(by=None, axis=0, level=None, as_index=True, sort=True, group_keys=True, squeeze=False, **kwargs)
举例进行说明:
import pandas as pd
df = pd.DataFrame(data={'books':['bk1','bk1','bk1','bk2','bk2','bk3'], 'price': [12,12,12,15,15,17]})
df

print (df.groupby('books', as_index=True).sum())

print (df.groupby('books', as_index=False).sum())

网友评论