commence par
Renvoie un booléen. La valeur est True si str start par le préfixe. Renvoie NULL si l'une des expressions d'entrée est NULL. Sinon, renvoie Faux. Les deux, str ou préfixe, doivent être de type STRING ou BINARY.
Pour la fonction Databricks SQL correspondante, consultez la fonctionstartswith.
Syntaxe
Python
from pyspark.sql import functions as dbf
dbf.startswith(str=<str>, prefix=<prefix>)
parameter
parameter | Type | Description |
|---|---|---|
|
| Une colonne de chaînes. |
|
| Une colonne de chaîne de caractères, le préfixe. |
Exemples
Python
df = spark.createDataFrame([("Spark SQL", "Spark",)], ["a", "b"])
df.select(startswith(df.a, df.b).alias('r')).collect()
Python
df = spark.createDataFrame([("414243", "4142",)], ["e", "f"])
df = df.select(to_binary("e").alias("e"), to_binary("f").alias("f"))
df.printSchema()
df.select(startswith("e", "f"), startswith("f", "e")).show()