Replace -inf with zero value
Question
I have an array:
x = numpy.array([-inf, -inf, 37.49668579])
Is there a way to change the -inf values to just 0?
La solution
There is:
from numpy import inf
x[x == -inf] = 0
Autres conseils
Use isneginf
http://docs.scipy.org/doc/numpy/reference/generated/numpy.isneginf.html#numpy.isneginf
x[numpy.isneginf(x)] = 0
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow