メインコンテンツまでスキップ

シータ差

Datasketches ANotB オブジェクトを使用して、Datasketches ThetaSketch オブジェクトの 2 つのバイナリ表現 (最初のスケッチにはあるが 2 番目のスケッチにはない要素) の差集合を返します。

構文

Python
from pyspark.sql import functions as sf

sf.theta_difference(col1, col2)

パラメーター

パラメーター

Type

説明

col1

pyspark.sql.Column または文字列

最初のThetaスケッチ。

col2

pyspark.sql.Column または文字列

2番目のThetaスケッチ。

戻り値

pyspark.sql.Column: 差のバイナリ表現ThetaSketch。

例1 : 2つのThetaスケッチの差を取得する

Python
from pyspark.sql import functions as sf
df = spark.createDataFrame([(1,4),(2,4),(3,5),(4,5)], "struct<v1:int,v2:int>")
df = df.agg(
sf.theta_sketch_agg("v1").alias("sketch1"),
sf.theta_sketch_agg("v2").alias("sketch2")
)
df.select(sf.theta_sketch_estimate(sf.theta_difference(df.sketch1, "sketch2"))).show()
Output
+---------------------------------------------------------+
|theta_sketch_estimate(theta_difference(sketch1, sketch2))|
+---------------------------------------------------------+
| 3|
+---------------------------------------------------------+