Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas isin

# Filter dataframe by multiple values in a column or multiple columns
# SQL equivalent: WHERE columnA IN ('val1', 'val2') AND columnB > 70

df[ (df.columnA.isin(['val1', 'val2'])) & (df['columnB'] > 70) ] 
Comment

pandas df isin

other = pd.DataFrame({'num_legs': [8, 3], 'num_wings': [0, 2]},
...                      index=['spider', 'falcon'])
>>> df.isin(other)
        num_legs  num_wings
falcon     False       True
dog        False      False
Comment

PREVIOUS NEXT
Code Example
Python :: strip in python 
Python :: get function in dictionary 
Python :: replace list 
Python :: join to dataframes pandas 
Python :: python tkinter entry hide text 
Python :: pandas get outliers 
Python :: map example in python 
Python :: python zip() 
Python :: numpy remove nan rows 
Python :: python read video frames 
Python :: how to take float input upto 2 decimal points in python 
Python :: python numpy array 
Python :: pairplot with selected field 
Python :: how to create a dictionary in python 
Python :: ffill dataframe python 
Python :: using a dictionary in python 
Python :: check if the user is logged in django decorator 
Python :: pi in python 
Python :: pandas drop missing values for any column 
Python :: pandas exclude rows from another dataframe 
Python :: convert pandas dataframe to dict with a column as key 
Python :: flask print request headers 
Python :: python regex get word after string 
Python :: python print f 
Python :: UnicodeDecodeError: ‘utf8’ codec can’t decode byte 
Python :: get week from datetime python 
Python :: python read excel 
Python :: discord bot delete messages python 
Python :: dataframe to pandas 
Python :: pyodbc cursor create list of dictionaries 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =