startswith (colonne)
Vérifiez si une colonne de chaînes de caractères start par une sous-chaîne.
Syntaxe
Python
startswith(other)
parameter
parameter | Type | Description |
|---|---|---|
| str or Column | Chaîne ou colonne contenant le préfixe à vérifier. |
Renvoie
Colonne (booléen)
Exemples
Python
df = spark.createDataFrame(
[(2, "Alice"), (5, "Bob")], ["age", "name"])
df.filter(df.name.startswith('Al')).collect()
Output
# [Row(age=2, name='Alice')]
Python
df.filter(df.name.startswith('^Al')).collect()
Output
# []