pyspark.sql.functions.expr#
- pyspark.sql.functions.expr(str)[source]#
- Parses the expression string into the column that it represents - New in version 1.5.0. - Changed in version 3.4.0: Supports Spark Connect. - Parameters
- strexpression string
- expression defined in string. 
 
- Returns
- Column
- column representing the expression. 
 
 - Examples - >>> import pyspark.sql.functions as sf >>> df = spark.createDataFrame([["Alice"], ["Bob"]], ["name"]) >>> df.select("*", sf.expr("length(name)")).show() +-----+------------+ | name|length(name)| +-----+------------+ |Alice| 5| | Bob| 3| +-----+------------+