pyspark.sql.functions.right#

pyspark.sql.functions.right(str, len)[source]#

Returns the rightmost len`(`len can be string type) characters from the string str, if len is less or equal than 0 the result is an empty string.

New in version 3.5.0.

Parameters
strColumn or str

Input column or strings.

lenColumn or str

Input column or strings, the rightmost len.

Examples

>>> df = spark.createDataFrame([("Spark SQL", 3,)], ['a', 'b'])
>>> df.select(right(df.a, df.b).alias('r')).collect()
[Row(r='SQL')]