I would like to create a new column with a numeric value based on the following conditions:
and. if gender is male and pet1 = pet2, points = 5
b. if the gender is female and (pet1 - "cat" or pet1 = "dog"), points = 5
with. all other combinations, points = 0
gender pet1 pet2
0 male dog dog
1 male cat cat
2 male dog cat
3 female cat squirrel
4 female dog dog
5 female squirrel cat
6 squirrel dog cat
I would like the end result to be as follows:
gender pet1 pet2 points
0 male dog dog 5
1 male cat cat 5
2 male dog cat 0
3 female cat squirrel 5
4 female dog dog 5
5 female squirrel cat 0
6 squirrel dog cat 0
How to do it?
source
share