I have an array:
x = numpy.array([-inf, -inf, 37.49668579])
Is there a way to change the -inf values to just 0?
Step 1: Select the range that you will work with. Step 2: Press the F5 key to open the Go To dialog box. Step 3: Click the Special button, and it opens the Go to Special dialog box. Step 6: Now just enter 0 or any other value that you need to replace the errors, and press Ctrl + Enter keys.
To replace zero with previous value in an R data frame column, we can use na. locf function of zoo package but to apply this we first need to replace the zero values with NA.
There is:
from numpy import inf x[x == -inf] = 0
Use isneginf
http://docs.scipy.org/doc/numpy/reference/generated/numpy.isneginf.html#numpy.isneginf
x[numpy.isneginf(x)] = 0
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