הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
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.
For the corresponding Databricks SQL function, see substr function.
Syntax
from pyspark.sql import functions as dbf
dbf.substr(str=<str>, pos=<pos>, len=<len>)
Parameters
| Parameter | Type | Description |
|---|---|---|
str |
pyspark.sql.Column or str |
A column of string. |
pos |
pyspark.sql.Column or str |
A column of string, the substring of str that starts at pos. |
len |
pyspark.sql.Column or str, optional |
A column of string, the substring of str is of length len. |
Returns
pyspark.sql.Column: substring of given value.
Examples
from pyspark.sql import functions as dbf
df = spark.createDataFrame([("Spark SQL", 5, 1,)], ["a", "b", "c"])
df.select("*", dbf.substr("a", "b", "c")).show()
df.select("*", dbf.substr(df.a, df.b)).show()