pandas基础_2
pandas
groupby练习
df = pd.DataFrame({'A':['foo','bar','foo','bar','foo','bar','foo','foo'],
'B':['one','one','two','three','two','two','one','three'],
'C':np.random.randn(8),
'D':np.random.randn(8)})
print(df)
grouped = df.groupby('A')
print(grouped.count())
'''
B C D
A
bar 3 3 3
foo 5 5 5
'''
grouped = df.groupby(['A','B'])
p
pandas基础_2最先出现在Python成神之路。
共有 0 条评论