ビットアンド
すべての非 null 入力値のビット単位の AND を返します。入力値がない場合は null を返します。
構文
Python
from pyspark.sql import functions as sf
sf.bit_and(col)
パラメーター
パラメーター | Type | 説明 |
|---|---|---|
|
| ターゲットカラムをコンピュートに。 |
戻り値
pyspark.sql.Column: すべての非 null 入力値のビットごとの AND。入力値がない場合は null。
例
例1 : すべての非NULL値とのビットAND
Python
from pyspark.sql import functions as sf
df = spark.createDataFrame([[1],[1],[2]], ["c"])
df.select(sf.bit_and("c")).show()
Output
+----------+
|bit_and(c)|
+----------+
| 0|
+----------+
例2 : null値を含むビットAND
Python
from pyspark.sql import functions as sf
df = spark.createDataFrame([[1],[None],[2]], ["c"])
df.select(sf.bit_and("c")).show()
Output
+----------+
|bit_and(c)|
+----------+
| 0|
+----------+
例3 : すべてのNULL値を含むビットAND
Python
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()
Output
+----------+
|bit_and(c)|
+----------+
| NULL|
+----------+
例4 : 単一の入力値によるビットAND
Python
from pyspark.sql import functions as sf
df = spark.createDataFrame([[5]], ["c"])
df.select(sf.bit_and("c")).show()
Output
+----------+
|bit_and(c)|
+----------+
| 5|
+----------+