Note
Ang pag-access sa pahinang ito ay nangangailangan ng pahintulot. Maaari mong subukang mag-sign in o magpalit ng mga direktoryo.
Ang pag-access sa pahinang ito ay nangangailangan ng pahintulot. Maaari mong subukang baguhin ang mga direktoryo.
Trim the spaces from both ends for the specified string column.
For the corresponding Databricks SQL function, see trim function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.trim(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 |
Returns
pyspark.sql.Column: trimmed values from both sides.
Examples
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([" Spark", "Spark ", " Spark"], "STRING")
df.select("*", dbf.trim("value")).show()
df = spark.createDataFrame(["***Spark", "Spark**", "*Spark"], "STRING")
df.select("*", dbf.trim("value", dbf.lit("*"))).show()
df = spark.createDataFrame([("**Spark*", "*"), ("==Spark=", "=")], ["value", "t"])
df.select("*", dbf.trim("value", "t")).show()