I have six variables (they are a column in my dataset), for example
A B value_old
aaa x 0
aaa y 0
aaa z 0
bbb x 0.4
bbb y 0.2
bbb z -0.01
I want to get a new set of values based on the signs of value_old (only compare the values if they have the same value in column 'A')
for 'aaa':
if value_old = 0, the new set value is 0.2
if value_old >0, the new set value is 10
if value_old <0, the new set value is 5
Expected output:
A B value_old value_new
aaa x 0 0.2
aaa y 0 0.2
aaa z 0 0.2
bbb x 0.4 10
bbb y 0.2 10
bbb z -0.01 5
Aucun commentaire:
Enregistrer un commentaire