I have the following DataFrame df1:
A
0 E2
1 27
2 99
3 NaN
4 20
5 14
And the following list:
list1 = [14, 61, 27, 82, 79, 75, 44, 10, 'E2','E9']
I want to add/append a new column called 'B' to df1 that checks whether the values in column 'A' are in list1 by returning a boolean.
Ultimately, I would want the following output in df1:
A B
0 E2 True
1 27 True
2 99 False
3 NaN False
4 20 False
5 14 True
Most of the questions I have seen regarding this have been when the length of the DataFrame column has been the same as the length of the list.
Does anyone know how to do this when the lengths are different like in this case?
Thanks a lot!
