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!
And if you are like me and swear by the name of list comprehension, try this:
abs_a = [-i if i <0 else i for i in a ]
Where abs_a stands for the absolute value of a
abs_a isn't even a ndarray).
numpy.absshould do itprint(abs(-6))show you : 6