pyspark.sql.Column.substr

Column.substr(startPos, length)[source]

Return a Column which is a substring of the column.

New in version 1.3.0.

Parameters
startPosColumn or int

start position

lengthColumn or int

length of the substring

Examples

>>> df.select(df.name.substr(1, 3).alias("col")).collect()
[Row(col='Ali'), Row(col='Bob')]