h3_toparent
Returns the parent H3 cell ID of the input H3 cell ID at the specified resolution. Supports Spark Connect.
For the corresponding Databricks SQL function, see h3_toparent function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.h3_toparent(col1=<col1>, col2=<col2>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| An H3 cell ID, represented as a BIGINT or a string |
|
| The resolution of the parent H3 cell ID to return. Must be non-negative and smaller or equal to the resolution of the first argument. |
Examples
Python
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()
Output
[Row(result=577199624117288959)]
Python
df.select(dbf.h3_toparent('h3l', 0).alias('result')).collect()
Output
[Row(result=577199624117288959)]