pyspark.sql.functions.btrim#

pyspark.sql.functions.btrim(str, trim=None)[source]#

Remove the leading and trailing trim characters from str.

New in version 3.5.0.

Parameters
strColumn or str

Input column or strings.

trimColumn or str, optional

The trim string characters to trim, the default value is a single space

Examples

>>> df = spark.createDataFrame([("SSparkSQLS", "SL", )], ['a', 'b'])
>>> df.select(btrim(df.a, df.b).alias('r')).collect()
[Row(r='parkSQ')]
>>> df = spark.createDataFrame([("    SparkSQL   ",)], ['a'])
>>> df.select(btrim(df.a).alias('r')).collect()
[Row(r='SparkSQL')]