numpy.cumprod() in Python Last Updated : 28 Nov, 2018 Comments Improve Suggest changes Like Article Like Report numpy.cumprod() function is used when we want to compute the cumulative product of array elements over 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. -> If provided, it must have a shape that the inputs broadcast to. -> If not provided or None, a freshly-allocated array is returned. Return : A new array holding the result is returned unless out is specified, in which case it is returned. Code #1 : Working Python # Python program explaining # numpy.cumprod() function import numpy as geek in_num = 10 print ("Input number : ", in_num) out_prod = geek.cumprod(in_num) print ("cumulative product of input number : ", out_prod) Output : Input number : 10 cumulative product of input number : [10] Code #2 : Python # 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 : Python # 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, axis = 1) print ("cumulative product of array elements taking axis 1: ", out_prod) Output : Input array : [[2 4 6] [1 3 5]] cumulative product of array elements taking axis 1: [[ 2 8 48] [ 1 3 15]] Comment More infoAdvertise with us Next Article numpy.cumprod() in Python jana_sayantan Follow Improve Article Tags : Python Python-numpy Python numpy-Mathematical Function Practice Tags : python Similar Reads numpy.cumsum() in Python numpy.cumsum() function is used to compute the cumulative sum of elements in an array. Cumulative sum refers to a sequence where each element is the sum of all previous elements plus itself. For example, given an array [1, 2, 3, 4, 5], the cumulative sum would be [1, 3, 6, 10, 15]. Let's implement t 3 min read numpy.nancumprod() in Python numpy.nancumprod() function is used when we want to compute the cumulative product of array elements over a given axis treating Not a Numbers (NaNs) as one. The cumulative product does not change when NaNs are encountered and leading NaNs are replaced by ones. Ones are returned for slices that are a 3 min read numpy.add() in Python NumPy, the Python powerhouse for scientific computing, provides an array of tools to efficiently manipulate and analyze data. Among its key functionalities lies numpy.add() a potent function that performs element-wise addition on NumPy arrays. numpy.add() SyntaxSyntax :Â numpy.add(arr1, arr2, /, out= 4 min read numpy.exp() in Python numpy.exp(array, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) : This mathematical function helps user to calculate exponential of all the elements in the input array. Parameters : array : [array_like]Input array or object whose elements, we need to test. out : [ndarray 4 min read numpy.ceil() in Python The numpy.ceil() is a mathematical function that returns the ceil of the elements of array. The ceil of the scalar x is the smallest integer i, such that i >= x Syntax : numpy.ceil(x[, out]) = ufunc âceilâ) Parameters : a : [array_like] Input array Return : The ceil of each element with float dat 2 min read NumPy Array in Python NumPy (Numerical Python) is a powerful library for numerical computations in Python. It is commonly referred to multidimensional container that holds the same data type. It is the core data structure of the NumPy library and is optimized for numerical and scientific computation in Python. Table of C 2 min read numpy.asscalar() in Python numpy.asscalar() function is used when we want to convert an array of size 1 to its scalar equivalent. Syntax : numpy.asscalar(arr) Parameters : arr : [ndarray] Input array of size 1. Return : Scalar representation of arr. The output data type is the same type returned by the inputâs item method. Co 1 min read Numpy recarray.cumprod() function | Python In numpy, arrays may have a data-types containing fields, analogous to columns in a spreadsheet. An example is [(a, int), (b, float)], where each entry in the array is a pair of (int, float). Normally, these attributes are accessed using dictionary lookups such as arr['a'] and arr['b']. Record array 2 min read numpy.nanprod() in Python numpy.nanprod() function is used when we want to compute the product of array elements over a given axis treating NaNs as ones. One is returned for slices that are all-NaN or empty. Syntax : numpy.nanprod(arr, axis=None, dtype=None, out=None, keepdims='class numpy._globals._NoValue'). Parameters : a 2 min read Python | Pandas Panel.cumprod() In Pandas, Panel is a very important container for three-dimensional data. The names for the 3 axes are intended to give some semantic meaning to describing operations involving panel data and, in particular, econometric analysis of panel data. Panel.cumprod() function is used to returns a DataFrame 1 min read Like