r/learnpython • u/blackgarliccookie • 2d ago
Turn these two variables into 1
I'm trying to turn these two variables, this is for homework so I'm gonna call it something else. I want to turn people1 and people2 into 1 variable.
people1 has two values, "not green" and "green". people2 has two values as well, "not purple" and "purple".
I want to make it so that everyone with "not green" and "not purple" are combined into one label, but only if they have both, not just one. I am struggling so bad :(
I am using pandas in python also. Thank you.
Edit: I want something like this: https://www.reddit.com/u/blackgarliccookie/s/xkzPCrmyrB
View all comments
Show parent comment
1
u/blackgarliccookie 2d ago
Apologies, I'm newish to coding so I am unfamiliar with some of the terminology. I am trying to create a new variable. And I'm trying to say that, for the column/variable of person1, the possible answers that can be in each row, there are 2. "green" and "not green". If you look at the value_counts(), there is just green and not green.