I'm learning python and need to use list comprehensions to answer a question on an assignment, but can't figure out an error I'm getting. I have a dataframe with participants, their ages, and their scores across different tests. I tried to use list comprehension to get a list of scores from participants under a certain age,
df['scoreunder18'] = [row for row in df['score'] if df['Age'] < 18 in row]
but got the following error:
*** ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I tried
df['scoreunder18'] = [row for row in df['score'] if (df['Age'] < 18).item in row]
but that just returns the values from the score column without honoring the condition.
Any help would be appreciated please and thank you!