實(shí)例
import pandas as pd
data=pd.DataFrame({'a':['A','A','A','A'],'b':[50,50,30,30]})
去重
data.drop_duplicates() # 去除重復(fù)數(shù)據(jù)
data.drop_duplicates().reset_index(drop=True) # 去除重復(fù)數(shù)據(jù)壕鹉,并重新設(shè)置索引歧沪,舍棄原來的索引
data.drop_duplicates()#data中一行元素全部相同時(shí)才去除
data.drop_duplicates(['a','b'])#data根據(jù)’a','b'組合列刪除重復(fù)項(xiàng)秘案,默認(rèn)保留第一個(gè)出現(xiàn)的值組合。傳入?yún)?shù)keep='last'則保留最后一個(gè)