How to absolute in NumPy

You can find absolute value in the NumPy with the following code. If you want to learn Python, I highly recommend reading This Book.

How to absolute in NumPy
How to absolute in NumPy

Example 1

import numpy as np
a = np.array([-5, 10, -1.2, -0.6, 0.2 ])
b = np.absolute(a)
print(b)
[ 5.  10.   1.2  0.6  0.2]

Example 2

import numpy as np
a = np.array([[5 + 2j], [5j], [2 + 3j]])
b = np.absolute(a)
print(b)
[[5.38516481]
 [5.        ]
 [3.60555128]]

People are also reading:

Best Python Books

What is Computer Vision? Examples, Applications, Techniques

Books for Machine Learning (ML)

Free Learning Resources

Leave a Comment

Your email address will not be published.