pyspark.pandas.DataFrame.rmul#
- DataFrame.rmul(other)[source]#
Get Multiplication of dataframe and other, element-wise (binary operator *).
Equivalent to
other * dataframe
. With the reverse version, mul.Among flexible wrappers (add, sub, mul, div) to arithmetic operators: +, -, *, /, //.
- Parameters
- otherscalar
Any single data
- Returns
- DataFrame
Result of the arithmetic operation.
Examples
>>> df = ps.DataFrame({'angles': [0, 3, 4], ... 'degrees': [360, 180, 360]}, ... index=['circle', 'triangle', 'rectangle'], ... columns=['angles', 'degrees']) >>> df angles degrees circle 0 360 triangle 3 180 rectangle 4 360
Add a scalar with operator version which returns the same results. Also, the reverse version.
>>> df + 1 angles degrees circle 1 361 triangle 4 181 rectangle 5 361
>>> df.add(1) angles degrees circle 1 361 triangle 4 181 rectangle 5 361
>>> df.add(df) angles degrees circle 0 720 triangle 6 360 rectangle 8 720
>>> df + df + df angles degrees circle 0 1080 triangle 9 540 rectangle 12 1080
>>> df.radd(1) angles degrees circle 1 361 triangle 4 181 rectangle 5 361
Divide and true divide by constant with reverse version.
>>> df / 10 angles degrees circle 0.0 36.0 triangle 0.3 18.0 rectangle 0.4 36.0
>>> df.div(10) angles degrees circle 0.0 36.0 triangle 0.3 18.0 rectangle 0.4 36.0
>>> df.rdiv(10) angles degrees circle inf 0.027778 triangle 3.333333 0.055556 rectangle 2.500000 0.027778
>>> df.truediv(10) angles degrees circle 0.0 36.0 triangle 0.3 18.0 rectangle 0.4 36.0
>>> df.rtruediv(10) angles degrees circle inf 0.027778 triangle 3.333333 0.055556 rectangle 2.500000 0.027778
Subtract by constant with reverse version.
>>> df - 1 angles degrees circle -1 359 triangle 2 179 rectangle 3 359
>>> df.sub(1) angles degrees circle -1 359 triangle 2 179 rectangle 3 359
>>> df.rsub(1) angles degrees circle 1 -359 triangle -2 -179 rectangle -3 -359
Multiply by constant with the reverse version.
>>> df * 1 angles degrees circle 0 360 triangle 3 180 rectangle 4 360
>>> df.mul(1) angles degrees circle 0 360 triangle 3 180 rectangle 4 360
>>> df.rmul(1) angles degrees circle 0 360 triangle 3 180 rectangle 4 360
Floor Divide by constant with reverse version.
>>> df // 10 angles degrees circle 0.0 36.0 triangle 0.0 18.0 rectangle 0.0 36.0
>>> df.floordiv(10) angles degrees circle 0.0 36.0 triangle 0.0 18.0 rectangle 0.0 36.0
>>> df.rfloordiv(10) angles degrees circle inf 0.0 triangle 3.0 0.0 rectangle 2.0 0.0
Mod by constant with reverse version.
>>> df % 2 angles degrees circle 0 0 triangle 1 0 rectangle 0 0
>>> df.mod(2) angles degrees circle 0 0 triangle 1 0 rectangle 0 0
>>> df.rmod(2) angles degrees circle NaN 2 triangle 2.0 2 rectangle 2.0 2
Power by constant with reverse version.
>>> df ** 2 angles degrees circle 0.0 129600.0 triangle 9.0 32400.0 rectangle 16.0 129600.0
>>> df.pow(2) angles degrees circle 0.0 129600.0 triangle 9.0 32400.0 rectangle 16.0 129600.0
>>> df.rpow(2) angles degrees circle 1.0 2.348543e+108 triangle 8.0 1.532496e+54 rectangle 16.0 2.348543e+108