Numpy MaskedArray.power() function | Python
numpy.MaskedArray.power() function is used to compute element-wise base array raised to power from second array. It raise each base in arr1 to the positionally-corresponding power in arr2. arr1 and arr2 must be broadcastable to the same shape. Note that an integer type raised to a negative integer power will raise a
numpy.ma.power(arr1, arr2, third=None)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
arr1 : [ array_like ] The base masked array.
arr2 :[ array_like ] The exponents masked array.
third : [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 : [ ndarray] The bases in arr1 raised to the exponents in arr2.
Code #1 :
Input base array : [0 1 2 3 4 5]
Base Masked array : [0 1 2 3 -- 5]
Input exponent array : [0 2 1 4 2 3]
Exponent Masked array : [0 -- 1 4 -- 3]
Output masked array : [1 -- 2 81 -- 125]