DataFrame 按列分组groupby
import pandas as pd # 按列分组 data = {'A': ["aa", "bb", "cc", "bb"], 'B': [5, 6, 10, 7], 'C': [0, 10, 3, 12]} df = pd.DataFrame(data) print(df) print(df.groupby('A', as_index=False).sum('bb'))
本文来自博客园,作者:OTAKU_nicole,转载请注明原文链接:https://www.cnblogs.com/nicole-zhang/p/17614352.html