I have three columns dummy variables, 'dummy1', 'dummy2' and 'dummy3. I would like to create a new column with a new dummy, 'new_dummy', with 1 if at least one of dummies of before has a value 1. I am using python.
I have in mind something like this:
mydata['new_dummy'] = mydata.apply(lambda x: x['1'] if x['dummy1'] or x['dummy2'] or x['dummy3'] == '1' else x['0'], axis=1)
But it does not work. Give me an error saying "KeyError: '0'". Any idea why I have that error or any other method to do it?