Nóta
Teastaíonn údarú chun rochtain a fháil ar an leathanach seo. Is féidir leat triail a bhaint as shíniú isteach nó eolairí a athrú.
Teastaíonn údarú chun rochtain a fháil ar an leathanach seo. Is féidir leat triail a bhaint as eolairí a athrú.
Collection function: Returns the length of the array or map stored in the column. Supports Spark Connect.
For the corresponding Databricks SQL function, see size function.
Syntax
from pyspark.sql import functions as dbf
dbf.size(col=<col>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or str |
Name of column or expression. |
Returns
pyspark.sql.Column: length of the array/map.
Examples
from pyspark.sql import functions as dbf
df = spark.createDataFrame([([1, 2, 3],),([1],),([],)], ['data'])
df.select(dbf.size(df.data)).collect()
[Row(size(data)=3), Row(size(data)=1), Row(size(data)=0)]