I have a Probability column, some of the values are greater then 1. I am trying to iterate over every row of that column and change values to 0.99 for all > 0.99. Also I need to see if column 1 is equal to column 2. If yes Probability must be 0. And if column 3 is greater than 11 => set Probability to 0.
I have tried next things and these doesn't work. All of them tell me that my syntax is invalid:
test['Probability'] = test.apply(lambda r: '0.99' if r['Probability] == '0.99')
I also tried to write the next. And it doesn't work as well:
test['Probability'] = ['0.99' if a > '0.99',
'0.0' if b == c,
'0.0' if d > '11'
for a, b, c, d in zip(
list(test['Probability']),
list(test['Column 1']),
list(test['Column 2']),
list(test['Column 3'])
)]
Probability Column 1 Column 2 Column 3
1.13 2 2 13
0 34 12 2
0.1042 4 4 5
0.8 1 54 3
0.03 1 3 8
Thanks everyone for your help.
Aucun commentaire:
Enregistrer un commentaire