Reputation: 7
I have a data frame (enct) with two binary columns (008.45 and a04.7) and I would like to create a third column name "cdi" that would return True if there is at least one true in one of those two columns. Here's an example depicting the desired results:
008.45 a04.7 cdi
True False True
False False False
False True True
Here is the code that I have tried:
enct["cdi"] = enct.apply(lambda x: True if x == "True" in (x['008.45'], x["a04.7"]) else False)
Upvotes: 0
Views: 92