pyspark.sql.functions.pmod#

pyspark.sql.functions.pmod(dividend, divisor)[source]#

Returns the positive value of dividend mod divisor.

New in version 3.4.0.

Parameters
dividendstr, Column or float

the column that contains dividend, or the specified dividend value

divisorstr, Column or float

the column that contains divisor, or the specified divisor value

Returns
Column

positive value of dividend mod divisor.

Notes

Supports Spark Connect.

Examples

>>> from pyspark.sql.functions import pmod
>>> df = spark.createDataFrame([
...     (1.0, float('nan')), (float('nan'), 2.0), (10.0, 3.0),
...     (float('nan'), float('nan')), (-3.0, 4.0), (-10.0, 3.0),
...     (-5.0, -6.0), (7.0, -8.0), (1.0, 2.0)],
...     ("a", "b"))
>>> df.select(pmod("a", "b")).show()
+----------+
|pmod(a, b)|
+----------+
|       NaN|
|       NaN|
|       1.0|
|       NaN|
|       1.0|
|       2.0|
|      -5.0|
|       7.0|
|       1.0|
+----------+