[IPython-User] check for value in list of columns

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[IPython-User] check for value in list of columns

Vincent Davis
I have data that looks like this
VMONTH VDAYVYEAR MED1MED2 MED3MED4 MED5PATWT PATCODE
010 1593 6073524355 3384316475 999595686 1
1 1015 9310126 578917165 9000090000 956862
210 1593 578919675 3055390000 9000095686 3
3 1015 9360735 1786534495 9000090000 956864
410 1593 196755810 9000090000 9000095686 5

​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 why it does not work.
DF['med'] = (60735 in [DF['MED1'], DF['MED1']])

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()


Vincent Davis


_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: check for value in list of columns

Thomas Kluyver-2
On 29 July 2014 14:32, Vincent Davis <[hidden email]> wrote:
​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 why it does not work.

Hi Vincent,

This list is about IPython, and your question is about pandas. See this page for where to ask questions about pandas:
http://pandas.pydata.org/community.html

Thanks,
Thomas

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user