codingtcher.com
Theme Night
Home
Login

drop duplicates pandas multiple columns

Home » Tutorial Post » drop duplicates pandas multiple columns

pandas merge duplicate columns remove

#Create test data
df1 = pd.DataFrame(np.random.randint(100,size=(1000, 3)),columns=['A','B','C'])
df2 = pd.DataFrame(np.random.randint(100,size=(1000, 3)),columns=['B','C','D'])

pd.merge(df1, df2, how='inner', left_on=['B','C'], right_on=['B','C'])

remove duplicates based on two columns in dataframe

df.drop_duplicates(['A','B'],keep= 'last')

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 merge two dataframes remove duplicates

concat = pd.merge(data_1, data_2, how='inner')
Source: stackoverflow.com

Related Post