cudf.DataFrame.mod#

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

Get Modulo division of dataframe or series and other, element-wise (binary operator mod).

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

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 % 100
           angles  degrees
circle          0       60
triangle        3       80
rectangle       4       60
>>> df.mod(100)
           angles  degrees
circle          0       60
triangle        3       80
rectangle       4       60

Series

>>> import cudf
>>> series = cudf.Series([10, 20, 30])
>>> series
0    10
1    20
2    30
dtype: int64
>>> series.mod(4)
0    2
1    0
2    2
dtype: int64