Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

removing rows dataframe not in another dataframe using two columns

import pandas as pd

USERS = pd.DataFrame({'email':['a@g.com','b@g.com','b@g.com','c@g.com','d@g.com']})
print (USERS)
     email
0  a@g.com
1  b@g.com
2  b@g.com
3  c@g.com
4  d@g.com

EXCLUDE = pd.DataFrame({'email':['a@g.com','d@g.com']})
print (EXCLUDE)
     email
0  a@g.com
1  d@g.com
Comment

PREVIOUS NEXT
Code Example
Python :: how to create simple window in wxPython 
Python :: concatenar columnas en una del mismo dataset 
Python :: access kwargs in template django 
Python :: sum of values with none 
Python :: get element tag name beautfulsoup 
Python :: hypercorn initiate 
Python :: string float to round to 2dp python 
Python :: find average of list via for loop python 
Python :: mechanize python #5 
Python :: python how to close the turtle tab on click 
Python :: sort dictionary by values 
Python :: django rest DjangoModelPermissions include get 
Python :: django database specify schema 
Python :: java scirpt 
Python :: python program to convert csv file into pdf 
Python :: know functionality of any function using help 
Python :: # print random number 
Python :: average values in a list python 
Python :: xgb model prediction changes if i save and load the model 
Python :: Python getting content from xl range 
Python :: Code Example of Checking if a variable is None using == operator 
Python :: Grading program using if else 
Python :: merge sort dictionary python 
Python :: pandas version for python 3.9 
Python :: Sequential Execution EC2 
Python :: python subprocess call with no environment variable 
Python :: Python NumPy Shape function example verifying the value of last dimension 
Python :: Set changed size during iteration 
Python :: First CGI program 
Python :: Stacked or grouped bar char python 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =