You are viewing documentation about an older version (1.3.0). View latest version

snowflake.snowpark.DataFrame.select_expr¶

DataFrame.select_expr(*exprs: str | Iterable[str]) → DataFrame[source]¶

Projects a set of SQL expressions and returns a new DataFrame. This method is equivalent to select(sql_expr(...)) with select() and functions.sql_expr().

selectExpr() is an alias of select_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                    |
--------------------------------------------
Copy