remove duplicates pandas code example
Example 1: remove duplicate row in df
df = df.drop_duplicates()
Example 2: remove duplicates function python
def remove_dupiclates(list_):
new_list = []
for a in list_:
if a not in new_list:
new_list.append(a)
return new_list
Example 3: remove duplicates python
mylist = ["a", "b", "a", "c", "c"]
mylist = list(dict.fromkeys(mylist))
Example 4: remove duplicate columns python dataframe
df = df.loc[:,~df.columns.duplicated()]
Example 5: python remove duplicates
if mylist:
mylist.sort()
last = mylist[-1]
for i in range(len(mylist)-2, -1, -1):
if last == mylist[i]:
del mylist[i]
else:
last = mylist[i]
# Quicker if all elements are hashables:
mylist = list(set(mylist))
Example 6: df remove duplicate rows
df = df.drop_duplicates()
p