📅  最后修改于: 2023-12-03 15:04:21.130000             🧑  作者: Mango
The numpy.ndarray.__floordiv__()
method performs element-wise floor division of two arrays.
numpy.ndarray.__floordiv__(self, value, /, out=None, *, where=True, casting='same_kind', **kwargs)
self
: array_like
The array to be divided element-wise.value
: array_like or scalar
The divisor. It may be a scalar or an array, but must have the same shape as self
.out
: ndarray, optional
A location into which the result is stored.where
: array_like, optional
A boolean array which is broadcasted to match the dimensions of self
, and selects elements to operate on.casting
: {‘no’, ‘equiv’, ‘safe’, ‘same_kind’, ‘unsafe’}, optional
Controls what kind of data casting may occur.Returns the floor division of self
and value
, i.e., self // value
.
import numpy as np
a = np.array([10, 20, 30, 40])
b = np.array([3, 5, 7, 9])
print(np.floor_divide(a, b))
Output:
array([3, 4, 4, 4])
The numpy.ndarray.__floordiv__()
method is an efficient way to perform element-wise floor division of two arrays. It returns a new array containing the floor division of the two input arrays.