Share via


bit_xor

Returns the bitwise XOR of all non-null input values, or null if none.

Syntax

from pyspark.sql import functions as sf

sf.bit_xor(col)

Parameters

Parameter Type Description
col pyspark.sql.Column or column name Target column to compute on.

Returns

pyspark.sql.Column: the bitwise XOR of all non-null input values, or null if none.

Examples

Example 1: Bitwise XOR with all non-null values

from pyspark.sql import functions as sf
df = spark.createDataFrame([[1],[1],[2]], ["c"])
df.select(sf.bit_xor("c")).show()
+----------+
|bit_xor(c)|
+----------+
|         2|
+----------+

Example 2: Bitwise XOR with some null values

from pyspark.sql import functions as sf
df = spark.createDataFrame([[1],[None],[2]], ["c"])
df.select(sf.bit_xor("c")).show()
+----------+
|bit_xor(c)|
+----------+
|         3|
+----------+