共用方式為


h3_toparent

在指定解析度中,回傳輸入的 H3 cell ID 的父 H3 cell ID。 支援 Spark Connect。

關於對應的 Databricks SQL 函式,請參見 h3_toparent 函數

語法

from pyspark.databricks.sql import functions as dbf

dbf.h3_toparent(col1=<col1>, col2=<col2>)

參數

參數 類型 Description
col1 pyspark.sql.Columnstr H3 儲存格 ID,表示為 BIGINT 或字串
col2 pyspark.sql.Columnstrint 父 H3 細胞 ID 的解析度會回傳。 必須是非負且小於或等於第一個參數的解析度。

範例

from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(599686042433355775, 0,)], ['h3l', 'res'])
df.select(dbf.h3_toparent('h3l', 'res').alias('result')).collect()
[Row(result=577199624117288959)]
df.select(dbf.h3_toparent('h3l', 0).alias('result')).collect()
[Row(result=577199624117288959)]