Σημείωση
Η πρόσβαση σε αυτή τη σελίδα απαιτεί εξουσιοδότηση. Μπορείτε να δοκιμάσετε να συνδεθείτε ή να αλλάξετε καταλόγους.
Η πρόσβαση σε αυτή τη σελίδα απαιτεί εξουσιοδότηση. Μπορείτε να δοκιμάσετε να αλλάξετε καταλόγους.
Returns the bitwise AND of all non-null input values, or null if none.
Syntax
from pyspark.sql import functions as sf
sf.bit_and(col)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or column name |
Target column to compute on. |
Returns
pyspark.sql.Column: the bitwise AND of all non-null input values, or null if none.
Examples
Example 1: Bitwise AND with all non-null values
from pyspark.sql import functions as sf
df = spark.createDataFrame([[1],[1],[2]], ["c"])
df.select(sf.bit_and("c")).show()
+----------+
|bit_and(c)|
+----------+
| 0|
+----------+
Example 2: Bitwise AND with null values
from pyspark.sql import functions as sf
df = spark.createDataFrame([[1],[None],[2]], ["c"])
df.select(sf.bit_and("c")).show()
+----------+
|bit_and(c)|
+----------+
| 0|
+----------+
Example 3: Bitwise AND with all null values
from pyspark.sql import functions as sf
from pyspark.sql.types import IntegerType, StructType, StructField
schema = StructType([StructField("c", IntegerType(), True)])
df = spark.createDataFrame([[None],[None],[None]], schema=schema)
df.select(sf.bit_and("c")).show()
+----------+
|bit_and(c)|
+----------+
| NULL|
+----------+
Example 4: Bitwise AND with single input value
from pyspark.sql import functions as sf
df = spark.createDataFrame([[5]], ["c"])
df.select(sf.bit_and("c")).show()
+----------+
|bit_and(c)|
+----------+
| 5|
+----------+