按列分组以在另一列中查找最频繁的值。例子:
import pandas as pd
d = {'col1': ['green','green','green','blue','blue','blue'],'col2': ['gx','gx','ow','nb','nb','mj']}
df = pd.DataFrame(data=d)
df
给出:
col1 col2
green gx
green gx
green ow
blue nb
blue nb
blue xv
结果:
因为green拥有gx和blue拥有nb
慕斯709654
相关分类