jeudi 21 juillet 2016

Python Pandas DataFrame check if string is other string and fill column

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

Aucun commentaire:

Enregistrer un commentaire