-1
Hello, I have an array with several values. I would like to replace the values above -0.54 to 1 and the values below -0.54 to 0.
Below is my results name array:
array([-2.06133692, 0.3721 , -1.35233125, -2.05725375, 0.39800875,
-2.0544975 , 0.66408308, -1.5466 , 0.66212308, -2.559165 ,])
I tried to use the following code:
for x in resultados:
if x > -0.54:
resultados = 1
else:
resultados = 0
But what I get at the end is the value 0. I believe it iterates in the array and only stores each element, hence the latter is smaller, saves as 0 result.
The doubt may seem simple, but I’ve been stuck in it for a long time, and I don’t know how to solve it. Thanks in advance.
Thank you very much!
– Ramon Tanoeiro