Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python check column conditions

from pandas import DataFrame
 
names = {'First_name': ['Hanah', 'Ria', 'Jay', 'Bholu', 'Sachin']}
df = DataFrame(names, columns =['First_name'])
 
df.loc[(df['First_name'] == 'Ria') | (df['First_name'] == 'Jay'), 'Status'] = 'Found' 
df.loc[(df['First_name'] != 'Ria') & (df['First_name'] != 'Jay'), 'Status'] = 'Not Found' 
 
print (df)
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #python #check #column #conditions
ADD COMMENT
Topic
Name
6+6 =