Series.pow() — method of mathematical operation series. This is used to mark each element of the missing series as the exponential power of the caller series and return the results. For this, the index of both series must be the same, otherwise an error is returned.
Syntax: Series.pow (other, = None, fill_value = None, axis = 0 )
other: Other series or list type to be put as exponential power to the caller series
level: Value to be replaced by NaN in series / list before operation
fill_value: Integer value of level in case of multi index
Return: Value of caller series with other series as its exponential power
Example # 1:
This example has two series are created using the Pandas .Series () method. None of the rows have zero values. The second series is directly passed as another parameter to return values after the operation.
As shown in the output, the returned values are equal to the first run with the second run as the exponential.
0 1 1 8 2 25 3 6 4 27 5 16 dtype: int64 pre >
Example # 2: Handling Null Values
This example also puts NaN values in a row using the numpy.nan method. After that, 2 is passed to the fill_value parameter to replace the zero values with 2.
As shown in the output, all NaN values were replaced with 2s before the operation, and the result was returned without a Null value.
0 1.0 1 4.0 2 125.0 3 36.0 4 9.0 5 2.0 6 64.0 7 4.0 dtype: float64