I have [6, -1, -3, -5]. I want to make the negative values positive, e.g. [6, 1, 3, 5]. Is there an easy way to do this?
Thank you so much, in advance!
Simply use the builtin abs function:
>>> a = np.array( [6, -1, -3, -5])
>>> a
array([ 6, -1, -3, -5])
>>> abs(a)
array([6, 1, 3, 5])
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