pyspark.sql.functions.substr#
- pyspark.sql.functions.substr(str, pos, len=None)[source]#
- Returns the substring of str that starts at pos and is of length len, or the slice of byte array that starts at pos and is of length len. - New in version 3.5.0. - Parameters
 - Examples - >>> import pyspark.sql.functions as sf >>> spark.createDataFrame( ... [("Spark SQL", 5, 1,)], ["a", "b", "c"] ... ).select(sf.substr("a", "b", "c")).show() +---------------+ |substr(a, b, c)| +---------------+ | k| +---------------+ - >>> import pyspark.sql.functions as sf >>> spark.createDataFrame( ... [("Spark SQL", 5, 1,)], ["a", "b", "c"] ... ).select(sf.substr("a", "b")).show() +------------------------+ |substr(a, b, 2147483647)| +------------------------+ | k SQL| +------------------------+