I am trying to save the 'yes' or 'no' results into a list that is named as outlier here.
This is my code
d = {'col1': [1, 2, 3, 4, 5], 'Spread': [10, 10.8, 5.0, 4.9,12.3]}
df = pd.DataFrame(d)
upper_limit = 9
rows = df.index.tolist()
outlier = []
for i in rows:
if df.Spread[i]>upper_limit:
result = print('yes') in outlier
else:
result = print('no') in outlier
and my output is like this
yes
yes
no
no
yes
after this loop, if I print outlier, it will only return to an empty list. What did I go wrong at this stage? How do I save 'yes' or 'no' results in the list?
Thanks in advance!
updated!