Return the product of array elements over a given axis. Parameters ---------- a : array_like Input data. axis : None or int or tuple of ints, optional Axis or axes along which a product is performed. The default, axis=None, will calculate the product of
(a, axis=None, dtype=None, out=None, keepdims=np._NoValue,
initial=np._NoValue, where=np._NoValue)
| 3324 | |
| 3325 | @array_function_dispatch(_prod_dispatcher) |
| 3326 | def prod(a, axis=None, dtype=None, out=None, keepdims=np._NoValue, |
| 3327 | initial=np._NoValue, where=np._NoValue): |
| 3328 | """ |
| 3329 | Return the product of array elements over a given axis. |
| 3330 | |
| 3331 | Parameters |
| 3332 | ---------- |
| 3333 | a : array_like |
| 3334 | Input data. |
| 3335 | axis : None or int or tuple of ints, optional |
| 3336 | Axis or axes along which a product is performed. The default, |
| 3337 | axis=None, will calculate the product of all the elements in the |
| 3338 | input array. If axis is negative it counts from the last to the |
| 3339 | first axis. |
| 3340 | |
| 3341 | If axis is a tuple of ints, a product is performed on all of the |
| 3342 | axes specified in the tuple instead of a single axis or all the |
| 3343 | axes as before. |
| 3344 | dtype : dtype, optional |
| 3345 | The type of the returned array, as well as of the accumulator in |
| 3346 | which the elements are multiplied. The dtype of `a` is used by |
| 3347 | default unless `a` has an integer dtype of less precision than the |
| 3348 | default platform integer. In that case, if `a` is signed then the |
| 3349 | platform integer is used while if `a` is unsigned then an unsigned |
| 3350 | integer of the same precision as the platform integer is used. |
| 3351 | out : ndarray, optional |
| 3352 | Alternative output array in which to place the result. It must have |
| 3353 | the same shape as the expected output, but the type of the output |
| 3354 | values will be cast if necessary. |
| 3355 | keepdims : bool, optional |
| 3356 | If this is set to True, the axes which are reduced are left in the |
| 3357 | result as dimensions with size one. With this option, the result |
| 3358 | will broadcast correctly against the input array. |
| 3359 | |
| 3360 | If the default value is passed, then `keepdims` will not be |
| 3361 | passed through to the `prod` method of sub-classes of |
| 3362 | `ndarray`, however any non-default value will be. If the |
| 3363 | sub-class' method does not implement `keepdims` any |
| 3364 | exceptions will be raised. |
| 3365 | initial : scalar, optional |
| 3366 | The starting value for this product. See `~numpy.ufunc.reduce` |
| 3367 | for details. |
| 3368 | where : array_like of bool, optional |
| 3369 | Elements to include in the product. See `~numpy.ufunc.reduce` |
| 3370 | for details. |
| 3371 | |
| 3372 | Returns |
| 3373 | ------- |
| 3374 | product_along_axis : ndarray, see `dtype` parameter above. |
| 3375 | An array shaped as `a` but with the specified axis removed. |
| 3376 | Returns a reference to `out` if specified. |
| 3377 | |
| 3378 | See Also |
| 3379 | -------- |
| 3380 | ndarray.prod : equivalent method |
| 3381 | :ref:`ufuncs-output-type` |
| 3382 | |
| 3383 | Notes |
searching dependent graphs…