pandas.DataFrame.rpow#

DataFrame.rpow(other, axis='columns', level=None, fill_value=None)[source]#

Get Exponential power of dataframe and other, element-wise (binary operator rpow).

Equivalent to other ** dataframe, but with support to substitute a fill_value for missing data in one of the inputs. With reverse version, pow.

Among flexible wrappers (add, sub, mul, div, floordiv, mod, pow) to arithmetic operators: +, -, *, /, //, %, **.

Parameters:
otherscalar, sequence, Series, dict or DataFrame

Any single or multiple element data structure, or list-like object.

axis{0 or ‘index’, 1 or ‘columns’}

Whether to compare by the index (0 or ‘index’) or columns. (1 or ‘columns’). For Series input, axis to match Series index on.

levelint or label

Broadcast across a level, matching Index values on the passed MultiIndex level.

fill_valuefloat or None, default None

Fill existing missing (NaN) values, and any new element needed for successful DataFrame alignment, with this value before computation. If data in both corresponding DataFrame locations is missing the result will be missing.

Returns:
DataFrame

Result of the arithmetic operation.

See also

DataFrame.add

Add DataFrames.

DataFrame.sub

Subtract DataFrames.

DataFrame.mul

Multiply DataFrames.

DataFrame.div

Divide DataFrames (float division).

DataFrame.truediv

Divide DataFrames (float division).

DataFrame.floordiv

Divide DataFrames (integer division).

DataFrame.mod

Calculate modulo (remainder after division).

DataFrame.pow

Calculate exponential power.

Notes

Mismatched indices will be unioned together.

Examples

>>> df = pd.DataFrame({'angles': [0, 3, 4],
...                    'degrees': [3, 1, 3]},
...                   index=['circle', 'triangle', 'rectangle'])
>>> df
           angles  degrees
circle          0        3
triangle        3        1
rectangle       4        3

Calculate exponential power with a scalar.

>>> 2 ** df
           angles  degrees
circle          1        8
triangle        8        2
rectangle      16        8
>>> df.rpow(2)
           angles  degrees
circle          1        8
triangle        8        2
rectangle      16        8

Calculate exponential power with a list.

>>> [2, 3] ** df
           angles  degrees
circle          1       27
triangle        8        3
rectangle      16       27
>>> df.rpow([2, 3], axis='columns')
           angles  degrees
circle          1       27
triangle        8        3
rectangle      16       27