snowflake.snowpark.DataFrame.where¶
- DataFrame.where(expr: ColumnOrSqlExpr) DataFrame [source]¶
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
Column
expression or SQL text.