Divide each row by a vector element using NumPy Last Updated : 03 Oct, 2022 Comments Improve Suggest changes Like Article Like Report The following article depicts how to Divide each row by a vector element using NumPy. The vector element can be a single element, multiple element, or array. The division operator ( / ) is employed to produce the required functionality. We can divide rows of 1-D, 2-D, or even more types of arrays with vector elements and the following examples will help you understand better: Divide row by a vector element in a 1-D Numpy array In the example, we divide the rows of a 1-D Numpy array with a vector element i.e [15] Python3 # Importing Numpy module import numpy as np # Creating 1-D Numpy array n_arr = np.array([20, 30, 40]) print("Given 1-D Array:") print(n_arr) # Vector element vec = np.array([12]) print("\nVector element:") print(vec) # Dividing rows of 1-D array with vector element print("\nResultant Array") print(n_arr / vec[:,None]) Output: Divide each by a vector element in a 2-D Numpy array In the example, we divide each row by a vector element of a 2-D Numpy array with a vector element i.e [2.5] Python3 # Importing Numpy module import numpy as np # Creating 2-D Numpy array n_arr = np.array([[20, 35, 40], [10, 51, 25]]) print("Given 2-D Array:") print(n_arr) # Vector element vec = np.array([2.5]) print("\nVector element:") print(vec) # Dividing rows of 2-D array with vector element print("\nResultant Array") print(n_arr / vec[:,None]) Output: Divide row by a vector element in a 3-D Numpy array In the example, we divide the rows of a 3-D Numpy array with a vector element i.e [3, 3] Python3 # Importing Numpy module import numpy as np # Creating 3-D Numpy array n_arr = np.array([[[10, 25], [30, 45]], [[50, 65], [70, 85]]]) print("Given 3-D Array:") print(n_arr) # Vector element vec = np.array([3, 3]) print("\nVector element:") print(vec) # Dividing rows of 3-D array with vector element print("\nResultant Array") print(n_arr / vec[:,None]) Output: Comment More infoAdvertise with us Next Article Divide each row by a vector element using NumPy vanshgaur14866 Follow Improve Article Tags : Python Python-numpy Python numpy-arrayManipulation Practice Tags : python Similar Reads Find a matrix or vector norm using NumPy To find a matrix or vector norm we use function numpy.linalg.norm() of Python library Numpy. This function returns one of the seven matrix norms or one of the infinite vector norms depending upon the value of its parameters. Syntax: numpy.linalg.norm(x, ord=None, axis=None)Parameters: x: input ord: 2 min read How to create a vector in Python using NumPy NumPy is a general-purpose array-processing package. It provides a high-performance multidimensional array object, and tools for working with these arrays. It is the fundamental package for scientific computing with Python. Numpy is basically used for creating array of n dimensions. Vector are built 4 min read How to get element-wise true division of an array using Numpy? True Division in Python3 returns a floating result containing the remainder of the division. To get the true division of an array, NumPy library has a function numpy.true_divide(x1, x2). This function gives us the value of true division done on the arrays passed in the function. To get the element-w 2 min read How to inverse a matrix using NumPy In this article, we will see NumPy Inverse Matrix in Python before that we will try to understand the concept of it. The inverse of a matrix is just a reciprocal of the matrix as we do in normal arithmetic for a single number which is used to solve the equations to find the value of unknown variable 3 min read Divide one Hermite series by another in Python using NumPy In this article, we are going to see how to divide one Hermite series by another in Python using NumPy. The numpy hermdiv() method helps us divide one Hermite series by another. The quotient and remainder of two Hermite series, c1 / c2, are returned. The arguments are a series of coefficients from l 3 min read Like