pyspark.sql.functions.ltrim¶
-
pyspark.sql.functions.
ltrim
(col: ColumnOrName) → pyspark.sql.column.Column[source]¶ Trim the spaces from left end for the specified string value.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
Examples
>>> df = spark.createDataFrame([" Spark", "Spark ", " Spark"], "STRING") >>> df.select(ltrim("value").alias("r")).withColumn("length", length("r")).show() +-------+------+ | r|length| +-------+------+ | Spark| 5| |Spark | 7| | Spark| 5| +-------+------+