- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Return the element-wise remainder of division in Numpy
To return the element-wise remainder of division, use the numpy.remainder() method in Python Numpy. Here, the 1st parameter is the Dividend array. The 2nd parameter is the Divisor array.
Computes the remainder complementary to the floor_divide function. It is equivalent to the Python modulus operator''x1 % x2'' and has the same sign as the divisor x2. The MATLAB function equivalent to np.remainder is mod.
The out is a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
Steps
At first, import the required library −
import numpy as np
Create an array −
arr = np.array([3, 9, 14, 22, 76, 81, 91])
Display the array −
print("Array...
", arr)
Get the type of the array −
print("
Our Array type...
", arr.dtype)
Get the dimensions of the Array −
print("
Our Array Dimension...
",arr.ndim)
Get the shape of the Array −
print("
Our Array Shape...
",arr.shape)
To return the element-wise remainder of division, use the numpy.remainder() method in Python Numpy. Here, the 1st parameter is the Dividend array. The 2nd parameter is the Divisor array −
print("
Result (remainder)...
",np.remainder(arr, 7))
Example
import numpy as np # Create an array arr = np.array([3, 9, 14, 22, 76, 81, 91]) # Display the array print("Array...
", arr) # Get the type of the array print("
Our Array type...
", arr.dtype) # Get the dimensions of the Array print("
Our Array Dimension...
",arr.ndim) # Get the shape of the Array print("
Our Array Shape...
",arr.shape) # To return the element-wise remainder of division, use the numpy.remainder() method in Python Numpy # Here, the 1st parameter is the Dividend array # The 2nd parameter is the Divisor array print("
Result (remainder)...
",np.remainder(arr, 7))
Output
Array... [ 3 9 14 22 76 81 91] Our Array type... int64 Our Array Dimension... 1 Our Array Shape... (7,) Result (remainder)... [3 2 0 1 6 4 0]
- Related Articles
- Return the element-wise remainder of division with fmod() operation in Numpy
- Return the element-wise remainder of division with modulo operation in Numpy
- Return element-wise quotient and remainder simultaneously in Python Numpy
- Return the reciprocal of the argument element-wise in Numpy
- Return the remainder of division with dividend and divisor array-like in Numpy
- Return element-wise string multiple concatenation in Numpy
- Return an element-wise indication of the sign of a number in Numpy
- Return an element-wise indication of the sign of complex types in Numpy
- Return the base 10 logarithm of the input array element-wise in Numpy
- Compare two arrays and return the element-wise minimum in Numpy
- Compare two arrays and return the element-wise maximum in Numpy
- Return the element-wise square-root of a complex type array in Numpy
- Return the non-negative square-root of an array element-wise in Numpy
- Return element-wise string concatenation for two arrays of string in Numpy
- Return element-wise title cased version of string or Unicode in Numpy
