so I have a for loop that loops through countries and each country has either a yes or a no, I want the corresponding animal to be added to a list each time there is a yes triggered. For example, I have a list that goes
Countries = ['Germany','France'..etc etc]
my DF is something like this
animal Germany France
Rabbit yes yes
Bear no yes
...
I want a list of animals such that there is a yes for the countries selected in the countries list. So in the instance above, I would want
animal_list = [Rabbit, Rabbit, Bear]
and my main code goes something like this, I have my attempt below as well but it doesn't work. Is there a clean way of doing it?
Countries = ['Germany','France'..etc etc]
animals_list = []
for country in Countries:
animal_list = animal_list.append(df[df[country] == 'yes'],'animal'])
The for loop is required so I am unable to do it off the bat using pandas.