I am new to Python and I was trying to create a loop which would create two lists of people based on the condition. My Dataframe has three columns:
controln donated amount_donated
controln is the ID of a person, donated means whether a person donated money or not
I'd like to have a list of people who donated more than $1 and another one which checks if they donated more than $5. I tried making a loop :
above5=[]
above1=[]
for a,c in val1.iterrows():
a= val1['controln']
b = val1['donated']
c= val1['amount_donated']
for item in c:
if item >= 5 :
above5.append(a)
if 5> item >= 1 :
above1.append(a)
else:
print('No match')
print('Done')
However it does not work as it creates a list of series with all the IDs and not those meeting the conditions.
I tried also with above1.append((a,c))
but that also doesn't work.
Could anyone advise me on what should be changed?