numpy.cumprod()
is used when we want to calculate the cumulative product of array elements along a given axis.
Syntax : numpy.cumprod (arr, axis = None, dtype = None, out = None)
Parameters:
arr: [array_like] Array containing numbers whose cumulative product is desired. If arr is not an array, a conversion is attempted.
axis: Axis along which the cumulative product is computed. The default is to compute the product of the flattened array.
dtype: Type of the returned array, as well as of the accumulator in which the elements are multiplied. If dtype is not specified, it defaults to the dtype of arr, unless arr has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used instead.
out: [ndarray, optional] A location into which the result is stored.
 & gt; If provided, it must have a shape that the inputs broadcast to.
 & gt; If not provided or None, a freshlyallocated array is returned.Return: A new array holding the result is returned unless out is specified, in which case it is returned.
Code # 1: Work

Output:
Input number: 10 cumulative product of input number: [10]
Code # 2:
# Python program explaining
# numpy.cumprod () function
import
numpy as geek
in_arr
=
geek.array ([ [
2
,
4
,
6
], [
1
,
3
,
5
]])
print
(
"Input array:"
, in_arr)
out_prod
=
geek.cumprod (in_arr)
print
(
"cumulative product of array elements:"
, out_prod)
Output:
Input array: [[2 4 6] [1 3 5]] cumulative product of array elements: [2 8 48 48 144 720]
Code # 3:

Output:
Input array: [[2 4 6] [1 3 5]] cumulative product of array elements taking axis 1: [[2 8 48] [1 3 15]]
Shabbir Challawala has over 8 years of rich experience in providing solutions based on MySQL and PHP technologies. He is currently working with KNOWARTH Technologies. He has worked in various PHPbase...
10/07/2020
Taking into account the development of modern programming, especially the emerging programming languages that reflect modern practice, Numerical Programming: A Practical Guide for Scientists and...
08/08/2021
It would be easy for me to develop native apps using Java, C++ or ObjectiveC and I am also able to learn Kotlin, Dart or Swift, but things are much easier when you just use Python. I have done a Djan...
23/09/2020
Google BigQuery: The Definitive Guide PDF download. Data Warehousing, Analytics, and Machine Learning at Scale, 1st Edition, 2019. Work with petabytescale datasets while building a collaborative a...
31/08/2021