pyspark.sql.functions.endswith(str: ColumnOrName, suffix: ColumnOrName) → pyspark.sql.column.Column[source]

Returns a boolean. The value is True if str ends with suffix. Returns NULL if either input expression is NULL. Otherwise, returns False. Both str or suffix must be of STRING or BINARY type.

New in version 3.5.0.

strColumn or str

A column of string.

suffixColumn or str

A column of string, the suffix.


>>> df = spark.createDataFrame([("Spark SQL", "Spark",)], ["a", "b"])
>>>, df.b).alias('r')).collect()
>>> df = spark.createDataFrame([("414243", "4243",)], ["e", "f"])
>>> df ="e").alias("e"), to_binary("f").alias("f"))
>>> df.printSchema()
 |-- e: binary (nullable = true)
 |-- f: binary (nullable = true)
>>>"e", "f"), endswith("f", "e")).show()
|endswith(e, f)|endswith(f, e)|
|          true|         false|