pandas.DataFrame.rdiv#
- DataFrame.rdiv(other, axis='columns', level=None, fill_value=None)[source]#
Get Floating division of dataframe and other, element-wise (binary operator rtruediv).
Equivalent to
other / dataframe, but with support to substitute a fill_value for missing data in one of the inputs. With reverse version, truediv.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_valuescalar or None, default None
Fill NA values, whether present in the original data or introduced by alignment, with this value before computation. Positions where both inputs are NA are left unfilled and behave as NA does for the operation.
- Returns:
- DataFrame
Result of the arithmetic operation.
See also
DataFrame.addAdd DataFrames.
DataFrame.subSubtract DataFrames.
DataFrame.mulMultiply DataFrames.
DataFrame.divDivide DataFrames (float division).
DataFrame.truedivDivide DataFrames (float division).
DataFrame.floordivDivide DataFrames (integer division).
DataFrame.modCalculate modulo (remainder after division).
DataFrame.powCalculate exponential power.
Notes
Mismatched indices will be unioned together.
Examples
>>> df = pd.DataFrame({'angles': [0, 3, 4], ... 'degrees': [360, 180, 360]}, ... index=['circle', 'triangle', 'rectangle']) >>> df angles degrees circle 0 360 triangle 3 180 rectangle 4 360
Divide a scalar.
>>> 1 / df angles degrees circle inf 0.002778 triangle 0.333333 0.005556 rectangle 0.250000 0.002778
>>> df.rtruediv(1) angles degrees circle inf 0.002778 triangle 0.333333 0.005556 rectangle 0.250000 0.002778
Divide a list.
>>> [1, 2] / df angles degrees circle inf 0.005556 triangle 0.333333 0.011111 rectangle 0.250000 0.005556
>>> df.rtruediv([1, 2], axis='columns') angles degrees circle inf 0.005556 triangle 0.333333 0.011111 rectangle 0.250000 0.005556