创建示例数据框如下:
df2=pd.DataFrame(data={'A':[1,2,3,3,4,4,4,4],'B':['a','b','c','c','d','d','d','d'],'C':[11,22,33,33,44,44,44,44],'D':[11,22,33,33,44,44,44,44]})
print(df2.mode()) #求列众数
print(df2.loc[:,['A','C','D']].mode(axis=1)) #求特定列的行众数
df2.drop_duplicates(subset=['学生id'],keep='first',inplace=True)
按列去重,保留第一条记录;