df:
       cat116_O  cat116_S  cat116_T  cat116_U  cat116_Y  
 0       0.0       0.0       0.0       0.0       0.0  
 1       0.0       0.0       0.0       0.0       0.0  
expected output:
df(changed):
     cat116_O  cat116_S  cat116_T  cat116_U  cat116_Y  
 0      -1       -1        -1         -1        -1
 1      -1       -1        -1         -1        -1
code:
df.replace(0.0, -1)   
But its not working. I was able to do iteratively for each row and column but it is taking a lot of time. Where am I going wrong with the replace function in the code.
Sounds like you're interested to find out why your replace function is not working.
I think this might be what you're looking for:
df.replace(to_replace = 0.0, value = -1, inplace = True)
This will return float(-1.0) values as your your values are floats.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With