pmod
Returns the positive value of dividend mod divisor. Supports Spark Connect.
For the corresponding Databricks SQL function, see pmod function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.pmod(dividend=<dividend>, divisor=<divisor>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| the column that contains dividend, or the specified dividend value |
|
| the column that contains divisor, or the specified divisor value |
Returns
pyspark.sql.Column: positive value of dividend mod divisor.
Examples
Python
from pyspark.databricks.sql import functions as dbf
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("*", dbf.pmod("a", "b")).show()
Output
+-----+----+----------+
| a| b|pmod(a, b)|
+-----+----+----------+
| 1.0| NaN| NaN|
| NaN| 2.0| NaN|
| 10.0| 3.0| 1.0|
| NaN| NaN| NaN|
| -3.0| 4.0| 1.0|
|-10.0| 3.0| 2.0|
| -5.0|-6.0| -5.0|
| 7.0|-8.0| 7.0|
| 1.0| 2.0| 1.0|
+-----+----+----------+