I have a dataframe:
col1 col2 col3 col4 col5 2 3 4 5 2 0 0 3 2 4 0 0 0 0 3
I am trying to create a boolean column of True/False if one of the values in col2 , col3, and col4 is larger than 0.
For example, in second row, 3 and 2 are larger than 0, we have a value returned as True. In third row, all values are smaller than 0, it returns False.
My code is like this, can anyone help me fix it?
code = ('col2', 'col3', 'col4') df('boolean_col') = df.apply(lambda x: True if x in code else False) df