pyspark.sql.functions.ascii#

pyspark.sql.functions.ascii(col)[source]#

Computes the numeric value of the first character of the string column.

New in version 1.5.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or str

target column to work on.

Returns
Column

numeric value.

Examples

>>> df = spark.createDataFrame(["Spark", "PySpark", "Pandas API"], "STRING")
>>> df.select(ascii("value")).show()
+------------+
|ascii(value)|
+------------+
|          83|
|          80|
|          80|
+------------+