pyspark.sql.functions.array_size¶
-
pyspark.sql.functions.
array_size
(col: ColumnOrName) → pyspark.sql.column.Column[source]¶ Returns the total number of elements in the array. The function returns null for null input.
New in version 3.5.0.
- Parameters
- col
Column
or str target column to compute on.
- col
- Returns
Column
total number of elements in the array.
Examples
>>> df = spark.createDataFrame([([2, 1, 3],), (None,)], ['data']) >>> df.select(array_size(df.data).alias('r')).collect() [Row(r=3), Row(r=None)]