snowflake.snowpark.DataFrame.where¶
- DataFrame.where(expr: Union[Column, str]) DataFrame[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.30.0/snowpark-python/src/snowflake/snowpark/dataframe.py#L1810-L1864)¶
- Filters rows based on the specified conditional expression (similar to WHERE in SQL). - Examples: - >>> df = session.create_dataframe([[1, 2], [3, 4]], schema=["A", "B"]) >>> df_filtered = df.filter((col("A") > 1) & (col("B") < 100)) # Must use parenthesis before and after operator &. >>> # The following two result in the same SQL query: >>> df.filter(col("a") > 1).collect() [Row(A=3, B=4)] >>> df.filter("a > 1").collect() # use SQL expression [Row(A=3, B=4)] - Parameters:
- expr – a - Columnexpression or SQL text.
- _ast_stmt – when invoked internally, supplies the AST to use for the resulting dataframe.