startswith (列)

文字列列が部分文字列で始まるかどうかを確認します。

構文

startswith(other)

パラメーター

パラメーター タイプ 説明
other str または Column チェックするプレフィックスを含む文字列または列

返品

列 (ブール値)

例示

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()
# []