pyspark.sql.functions.url_encode

pyspark.sql.functions.url_encode(str: ColumnOrName) → pyspark.sql.column.Column[source]

Translates a string into ‘application/x-www-form-urlencoded’ format using a specific encoding scheme.

New in version 3.5.0.

Parameters
strColumn or str

A column of string to encode.

Examples

>>> df = spark.createDataFrame([("https://spark.apache.org",)], ["a"])
>>> df.select(url_encode(df.a).alias('r')).collect()
[Row(r='https%3A%2F%2Fspark.apache.org')]