pyspark.sql.DataFrame.selectExpr¶
-
DataFrame.
selectExpr
(*expr: Union[str, List[str]]) → pyspark.sql.dataframe.DataFrame¶ Projects a set of SQL expressions and returns a new
DataFrame
.This is a variant of
select()
that accepts SQL expressions.Examples
>>> df.selectExpr("age * 2", "abs(age)").collect() [Row((age * 2)=4, abs(age)=2), Row((age * 2)=10, abs(age)=5)]