nxcals.api.extraction.data.builders.DataFrame.selectExpr
- DataFrame.selectExpr(*expr: str) DataFrame
- DataFrame.selectExpr(*expr: List[str]) DataFrame
Projects a set of SQL expressions and returns a new
DataFrame
.This is a variant of
select()
that accepts SQL expressions.New in version 1.3.0.
Changed in version 3.4.0: Supports Spark Connect.
- Returns:
A DataFrame with new/old columns transformed by expressions.
- Return type:
Examples
>>> df = spark.createDataFrame([ ... (2, "Alice"), (5, "Bob")], schema=["age", "name"]) >>> df.selectExpr("age * 2", "abs(age)").show() +---------+--------+ |(age * 2)|abs(age)| +---------+--------+ | 4| 2| | 10| 5| +---------+--------+