Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

select rows which entries equals one of the values pandas

In[10]: df
Name     Amount
---------------
Alice       100
Bob          50
Charlie     200
Alice        30
Charlie      10

In [11]: df['Name'].isin(['Alice', 'Bob'])
Out[11]: 
0     True
1     True
2    False
3     True
4    False
Name: Name, dtype: bool

In [12]: df[df.Name.isin(['Alice', 'Bob'])]
Out[12]: 
    Name  Amount
0  Alice     100
1    Bob      50
3  Alice      30
Comment

PREVIOUS NEXT
Code Example
Python :: kneighbours regressor sklearn 
Python :: python selenium full screen 
Python :: normalize data python 
Python :: how to create a python venv 
Python :: python yaml load_all 
Python :: dictionary function fromkeys in python 
Python :: python df select first x columns 
Python :: django widgets 
Python :: python delete duplicate lines in file 
Python :: python inline conditional 
Python :: pyspark case when 
Python :: how to rename columns in python 
Python :: pyAudioAnalysis 
Python :: latency discord.py 
Python :: python get computer name 
Python :: convert list into integer python 
Python :: python convert string to date 
Python :: unnamed 0 pandas 
Python :: read excel file spyder 
Python :: python ignore unicodedecodeerror 
Python :: python get current month 
Python :: tuple with one element python 
Python :: pandas create new column and fill with constant value 
Python :: py how to deactivate venv 
Python :: Learn python 3 the hard way by by Zed Shaw 
Python :: current time python 
Python :: how to take unknown number of inputs in python 
Python :: python day of the week 
Python :: how to import model_to_dict 
Python :: extract url from page python 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =