Pandas Series: rpow() function
Exponential power of Pandas series
The rpow() function is used to get exponential power of series and other, element-wise (binary operator rpow).
Syntax:
Series.rpow(self, other, level=None, fill_value=None, axis=0)[source]
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
other | Series or scalar value | Required | |
fill_value | Fill existing missing (NaN) values, and any new element needed for successful Series alignment, with this value before computation. If data in both corresponding Series locations is missing the result will be missing. | None or float value Default Value: None (NaN) |
Required |
level | Broadcast across a level, matching Index values on the passed MultiIndex level. | int or name | Required |
Returns: Series
The result of the operation.
Example:
Python-Pandas Code:
import numpy as np
import pandas as pd
x = pd.Series([3, 2, 1, np.nan], index=['p', 'q', 'r', 's'])
x
Output:
p 3.0 q 2.0 r 1.0 s NaN dtype: float64
Python-Pandas Code:
import numpy as np
import pandas as pd
y = pd.Series([3, np.nan, 2, np.nan], index=['p', 'q', 's', 't'])
y
Output:
p 3.0 q NaN s 2.0 t NaN dtype: float64
Python-Pandas Code:
import numpy as np
import pandas as pd
x = pd.Series([3, 2, 1, np.nan], index=['p', 'q', 'r', 's'])
y = pd.Series([3, np.nan, 2, np.nan], index=['p', 'q', 's', 't'])
x.rpow(y, fill_value=0)
Output:
p 27.0 q 0.0 r 0.0 s 1.0 t NaN dtype: float64
Previous: Modulo of Pandas series and other
Next: Combine the Series with a Series in Pandas
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/pandas/series/series-rpow.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics