Python Pandas DataFrame check if string is other string and fill column
Question: I am learning Python and this might be a noob question:

    
    
    import pandas as pd
    
    A = pd.DataFrame({"A":["house", "mouse", "car", "tree"]})
    
    check_list = ["house", "tree"]
    

I want to check rowwise if the string in A is in check_list. The result should
be

    
    
           A   YESorNO
    0  house       YES
    1  mouse        NO
    2    car        NO
    3   tree       YES
    


Answer: Use
[`numpy.where`](http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.where.html)
with [`isin`](http://pandas.pydata.org/pandas-
docs/stable/generated/pandas.Series.isin.html):

    
    
    import pandas as pd
    import numpy as np
    
    A = pd.DataFrame({"A":["house", "mouse", "car", "tree"]})
    check_list = ["house", "tree"]
    
    A['YESorNO'] = np.where(A['A'].isin(check_list),'YES','NO')
    print (A)
           A YESorNO
    0  house     YES
    1  mouse      NO
    2    car      NO
    3   tree     YES
    

