I have a dataset of 3 columns, I want to make a fourth column by copying some of the values from one of them but with some specific rules. So I need the values of the number column, in the same row the score must be >= 11 and I don't need green and blue. I get a value error.
df = pd.DataFrame.from_dict({
'score': [6, 4, 3, 12, 32, 16, 4, 2, 9, 20],
'group': ['green', 'green', 'blue', 'blue', 'yellow', 'yellow', 'red', 'red', 'black', 'black'],
'number': [-1, 2, 2, 6, 3, 12, -4, 20, 9, 10],})
score group number
0 6 green -1
1 4 green 2
2 3 blue 2
3 12 blue 6
4 32 yellow 3
5 16 yellow 12
6 4 red -4
7 2 red 20
8 9 black 9
9 20 black 10
if df['score'] >=11\
and df['group'] != 'green'\
and df['group'] != 'blue':
df['finalnumber'] == df['number']
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().