snowflake.snowpark.DataFrame.filter¶
- DataFrame.filter(expr: Union[Column, str]) DataFrame [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/dataframe.py#L1640-L1694)¶
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._ast_stmt – when invoked internally, supplies the AST to use for the resulting dataframe.