Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

removing rows dataframe not in another dataframe using two columns

df = pd.merge(df1, df2, how='left', indicator='Exist')
df['Exist'] = np.where(df.Exist == 'both', True, False)
df = df[df['Exist']==True].drop(['Exist','z'], axis=1)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #removing #rows #dataframe #dataframe #columns
ADD COMMENT
Topic
Name
1+1 =