What are some common operations that can be applied to NumPy Arrays?


#1

Question

What are some common operations that can be applied to NumPy Arrays?

Answer

Most operations that you can apply on two numerical values in Python can also be applied to NumPy Arrays.

Common operations that are element-wise include addition, subtraction, multiplication, division, modulo and exponent.

Example of some operations

example = np.array([12, 34, 45, 67, 89])

example + 1
# [13, 35, 46, 68, 90]

example * 10
# [120, 340, 450, 670, 890]

example % 10
# [2, 4, 5, 7, 9]