cudf.DataFrame.rsub#

DataFrame.rsub(other, axis='columns', level=None, fill_value=None)#

Get Subtraction of dataframe or series and other, element-wise (binary operator rsub).

Equivalent to other - frame, but with support to substitute a fill_value for missing data in one of the inputs. With reverse version, sub.

Parameters
otherscalar, sequence, Series, or DataFrame

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

axisint or string

Only 0 is supported for series, 1 or columns supported for dataframe

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 or Series

Result of the arithmetic operation.

Examples

DataFrame

>>> import cudf
>>> df = cudf.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
>>> df.rsub(1)
           angles  degrees
circle          1     -359
triangle       -2     -179
rectangle      -3     -359
>>> df.rsub([1, 2])
           angles  degrees
circle          1     -358
triangle       -2     -178
rectangle      -3     -358

Series

>>> import cudf
>>> a = cudf.Series([1, 2, 3, None], index=['a', 'b', 'c', 'd'])
>>> a
a       1
b       2
c       3
d    <NA>
dtype: int64
>>> b = cudf.Series([1, None, 2, None], index=['a', 'b', 'd', 'e'])
>>> b
a       1
b    <NA>
d       2
e    <NA>
dtype: int64
>>> a.rsub(b, fill_value=10)
a       0
b       8
c       7
d      -8
e    <NA>
dtype: int64