PYTHON
python: remove duplicate in a specific column
df = df.drop_duplicates(subset=['Column1', 'Column2'], keep='first')
remove duplicate row in df
df = df.drop_duplicates()
remove duplicates based on two columns in dataframe
df.drop_duplicates(['A','B'],keep= 'last')
dataframe delete duplicate rows with same column value
df = df.drop_duplicates(subset=['Column1', 'Column2'], keep='first')
# Exemple
import pandas as pd
df = pd.DataFrame({"A":["foo", "foo", "foo", "bar"], "B":[0,1,1,1], "C":["A","A","B","A"]})
df.drop_duplicates(subset=['A', 'C'], keep=False)
pandas drop duplicates from column
data = data.drop_duplicates(subset=['City'], keep='first')
remove duplicate values in data frame r
dataframe delete duplicate rows with same column value
df = df.drop_duplicates(subset=['Column1', 'Column2'], keep='first')
# Exemple
import pandas as pd
df = pd.DataFrame({"A":["foo", "foo", "foo", "bar"], "B":[0,1,1,1], "C":["A","A","B","A"]})
df.drop_duplicates(subset=['A', 'C'], keep=False)
remove duplicate columns python dataframe
df = df.loc[:,~df.columns.duplicated()]
python pandas remove duplicates and make that change to same dataframe
# If same dataset needs to be updated:
df.drop_duplicates(keep=False, inplace=True)
drop row with duplicate value
import pandas as pd
df = pd.DataFrame({"A":["foo", "foo", "foo", "bar"], "B":[0,1,1,1], "C":["A","A","B","A"]})
df.drop_duplicates(subset=['A', 'C'], keep=False)
how to drop duplicate columns in pandas that dont have the same name?
# Drop duplicate columns
df2 = df.T.drop_duplicates().T
print(df2)
pandas remove duplicates columns
df = df.loc[:,~df.columns.duplicated()].copy()
# https://stackoverflow.com/questions/14984119/python-pandas-remove-duplicate-columns