snowflake.snowpark.DataFrame.selectExpr¶
- DataFrame.selectExpr(*exprs: Union[str, Iterable[str]]) DataFrame [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/dataframe.py#L1107-L1135)¶
Projects a set of SQL expressions and returns a new
DataFrame
. This method is equivalent toselect(sql_expr(...))
withselect()
andfunctions.sql_expr()
.selectExpr()
is an alias ofselect_expr()
.- Parameters:
exprs – The SQL expressions.
Examples:
>>> df = session.create_dataframe([-1, 2, 3], schema=["a"]) # with one pair of [], the dataframe has a single column and 3 rows. >>> df.select_expr("abs(a)", "a + 2", "cast(a as string)").show() -------------------------------------------- |"ABS(A)" |"A + 2" |"CAST(A AS STRING)" | -------------------------------------------- |1 |1 |-1 | |2 |4 |2 | |3 |5 |3 | --------------------------------------------