Search code examples
pythonarraysnumpyinfinity

Replace -inf with zero value


I have an array:

x =  numpy.array([-inf, -inf, 37.49668579])

Is there a way to change the -inf values to just 0?


Solution

  • There is:

    from numpy import inf
    x[x == -inf] = 0