pandas.DataFrame.drop_duplicates(self, subset=None, keep='first', inplace=False)
默认subset为全部列,但是可以自己指定
data=pd.DataFrame({'A':[2,2,3,2],'b':[2,3,2,2],'c':[2,2,1,3],'d':[1,1,3,3]}) data
data = data.drop_duplicates() data
data.drop_duplicates(subset=['A','b'], keep='last',inplace=True) # subset 参数表示的是对比哪几列 print(data)