Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Trim the spaces from left end for the specified string value.
For the corresponding Databricks SQL function, see ltrim function.
Syntax
from pyspark.sql import functions as dbf
dbf.ltrim(col=<col>, trim=<trim>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or str |
target column to work on. |
trim |
pyspark.sql.Column or str, optional |
The trim string characters to trim, the default value is a single space. Added in Databricks Runtime 16.1 |
Returns
pyspark.sql.Column: left trimmed values.
Examples
from pyspark.sql import functions as dbf
df = spark.createDataFrame([" Spark", "Spark ", " Spark"], "STRING")
df.select("*", dbf.ltrim("value")).show()
df = spark.createDataFrame(["***Spark", "Spark**", "*Spark"], "STRING")
df.select("*", dbf.ltrim("value", dbf.lit("*"))).show()
df = spark.createDataFrame([("**Spark*", "*"), ("==Spark=", "=")], ["value", "t"])
df.select("*", dbf.ltrim("value", "t")).show()