檢查字串欄位是否以子字串開頭。
語法
startswith(other)
參數
| 參數 | 類型 | 說明 |
|---|---|---|
other |
str 或 Column | 包含檢查前綴的字串或欄位 |
退貨
欄位(布林)
Examples
df = spark.createDataFrame(
[(2, "Alice"), (5, "Bob")], ["age", "name"])
df.filter(df.name.startswith('Al')).collect()
# [Row(age=2, name='Alice')]
df.filter(df.name.startswith('^Al')).collect()
# []