I have a pandas dataframe data that looks like this
MED1 MED2 MED3 MED4 MED5
0 60735 24355 33843 16475 9995
1 10126 5789 17165 90000 90000
2 5789 19675 30553 90000 90000
3 60735 17865 34495 90000 90000
4 19675 5810 90000 90000 90000
I want to create a new bool column "med" that has True/False based on 60735 in the columns MED1...MED5 I am trying this and am not sure how to make it work.
DF['med'] = (60735 in [DF['MED1'], DF['MED2']])
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
MED1..MED5 represent drugs being taken by a patient at a hospital visit. I have a list of about 20 drugs for which I need to know if the patien was taking them. Each drug is coded with a number but has a name. A nice solution would look something like (below) but how do I do this with pandas.
drugs = {'drug1':60735, 'drug2':5789}
for n in drugs.keys():
DF[n] = drugs[n] in DF[['MED1', 'MED2', 'MED3', 'MED4', 'MED5']]