Numpy is a very popular python module for doing array manipulation. In the last post, you have learned how to perform element wise multiplication in NumPy. In this entire tutorial, you will know how to do numpy element wise division. Here I will show you various methods and example to implement it.

Before going to coding demonstration and examples let’s import all the necessary libraries required. In this entire tutorial, I am using only the NumPy library lets import them.

`import numpy as np`

## Element Wise Division of 1D Numpy numpy

Let’s create a 1D numpy array using the method * numpy.array()* for performing division on all the elements of it. I will use two approaches. One is the divisive (/) operator and the other is the

*method. Let’s see it.*

**np.divide()**`array_1d = np.array([10,20,30,40,50])`

```
# using divisive operator
array_1d/10
```

**Output**

```
# using np.divide()
np.divide(array_1d,10)
```

**Output**

You can see, In both methods, the output will be the same.

## Element Wise Division of 2D Numpy Array

Now let’s perform the division on the two-dimensional NumPy arrays. Here I am using the same methods that I have done in the 1D array. But before it let’s create a 2d NumPy array.

`array_2d = np.array([[10,20,30],[40,50,60]])`

```
# using divisive operator
array_1d/10
```

**Output**

```
# using np.divide()
np.divide(array_1d,10)
```

**Output**

Again you are getting the same results in both cases. In the next section, you will look at other examples of the Numpy Element Wise Division.

## Other Examples on Numpy Division

### Element wise division using mean

In this example, I will divide each element of the NumPy array using the mean of the whole array. For the sake of simplicity, I am performing calculations on a 1D array only.

Execute the below lines of code.

```
import numpy as np
array_1d = np.array([10,20,30,40,50])
mean = np.mean(array_1d)
np.divide(array_1d,mean)
```

**Output**

### Numpy element wise division using max and min

Now, let’s divide each array element with the max of the entire array. To do so you have to pass two arguments in the* numpy.divide()*. One is the input array and the other is the result of

*. Just execute the code give below to see the output.*

**np.max()**```
import numpy as np
array_1d = np.array([10,20,30,40,50])
max = np.max(array_1d)
np.divide(array_1d,max)
```

**Output**

In the same way, you can do element-wise division with the min value.

```
import numpy as np
array_1d = np.array([10,20,30,40,50])
min = np.min(array_1d)
np.divide(array_1d,min)
```

**Output**

## Conclusion

That’s all for now. These are the methods to do the Element Wise Division. The method * numpy.divide()* is the faster method than the simpler ones. Therefore I prefer to use it. Hope you have liked this tutorial. If you have any queries then you can contact us.

Source:

#### Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.