pyspark.sql.functions.length#
- pyspark.sql.functions.length(col)[source]#
Computes the character length of string data or number of bytes of binary data. The length of character data includes the trailing spaces. The length of binary data includes binary zeros.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
Examples
>>> spark.createDataFrame([('ABC ',)], ['a']).select(length('a').alias('length')).collect() [Row(length=4)]