Answers for "drop duplicate index pandas"

0

pandas remove repeated index

df[~df.index.duplicated()]
Posted by: Guest on August-17-2020
1

drop duplicate index pandas

df3 = df3[~df3.index.duplicated(keep='first')]
Posted by: Guest on November-12-2020
0

pandas remove repeated index

idx = pd.Index(['lama', 'cow', 'lama', 'beetle', 'lama', 'hippo'])
idx.drop_duplicates(keep='first')
Index(['lama', 'cow', 'beetle', 'hippo'], dtype='object')
idx.drop_duplicates(keep='last')
Index(['cow', 'beetle','lamb', 'hippo'], dtype='object')
idx.drop_duplicates(keep='False')
Index(['cow', 'beetle','hippo'], dtype='object')
Posted by: Guest on August-17-2020

Python Answers by Framework

Browse Popular Code Answers by Language