Question: In this example Pokémon data, let's say we want to exclude any Pokémon that is both Type 1 = Dragon and Total = 600. That means we want to exclude just one record (highlighted below): import polars as pl df = pl.read_csv("https://gist.githubusercontent.com/ritchie46/cac6b337ea52281aa23c049250a4ff03/raw/89a957ff3919d90e6ef2d34235e6bf22304f3366/pokemon.csv") df = df.sort("Total", descending=True) df ┌─────┬───────────────────────────┬─────────┬─────────┬───────┬─────┬────────┬─────────┬─────────┬─────────┬───────┬────────────┬───────────┐ │ # ┆ Name ┆ Type 1 ┆ Type 2 ┆ Total ┆ HP ┆ Attack ┆ Defense ┆ Sp. Atk ┆ Sp. Def ┆ Speed ┆ Generation ┆ Legendary │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ │ i64 ┆ str ┆ str ┆ str ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆ bool │ ╞═════╪═══════════════════════════╪═════════╪═════════╪═══════╪═════╪════════╪═════════╪═════════╪═════════╪═══════╪════════════╪═══════════╡ │ 150 ┆ Mewtwo ┆ Psychic ┆ null ┆ 680 ┆ 106 ┆ 110 ┆ 90 ┆ 154 ┆ 90 ┆ 130 ┆ 1 ┆ true │ │ 130 ┆ GyaradosMega Gyarados ┆ Water ┆ Dark ┆ 640 ┆ 95 ┆ 155 ┆ 109 ┆ 70 ┆ 130 ┆ 81 ┆ 1 ┆ false │ │ 6 ┆ CharizardMega Charizard X ┆ Fire ┆ Dragon ┆ 634 ┆ 78 ┆ 130 ┆ 111 ┆ 130 ┆ 85 ┆ 100 ┆ 1 ┆ false │ │ 6 ┆ CharizardMega Charizard Y ┆ Fire ┆ Flying ┆ 634 ┆ 78 ┆ 104 ┆ 78 ┆ 159 ┆ 115 ┆ 100 ┆ 1 ┆ false │ │ 9 ┆ BlastoiseMega Blastoise ┆ Water ┆ null ┆ 630 ┆ 79 ┆ 103 ┆ 120 ┆ 135 ┆ 115 ┆ 78 ┆ 1 ┆ false │ │ 3 ┆ VenusaurMega Venusaur ┆ Grass ┆ Poison ┆ 625 ┆ 80 ┆ 100 ┆ 123 ┆ 122 ┆ 120 ┆ 80 ┆ 1 ┆ false │ │ 142 ┆ AerodactylMega Aerodactyl ┆ Rock ┆ Flying ┆ 615 ┆ 80 ┆ 135 ┆ 85 ┆ 70 ┆ 95 ┆ 150 ┆ 1 ┆ false │ │ 94 ┆ GengarMega Gengar ┆ Ghost ┆ Poison ┆ 600 ┆ 60 ┆ 65 ┆ 80 ┆ 170 ┆ 95 ┆ 130 ┆ 1 ┆ false │ │ 127 ┆ PinsirMega Pinsir ┆ Bug ┆ Flying ┆ 600 ┆ 65 ┆ 155 ┆ 120 ┆ 65 ┆ 90 ┆ 105 ┆ 1 ┆ false │ │ 149 ┆ ***Dragonite*** ┆*Dragon* ┆ Flying ┆*600* ┆ 91 ┆ 134 ┆ 95 ┆ 100 ┆ 100 ┆ 80 ┆ 1 ┆ false │ │ 65 ┆ AlakazamMega Alakazam ┆ Psychic ┆ null ┆ 590 ┆ 55 ┆ 50 ┆ 65 ┆ 175 ┆ 95 ┆ 150 ┆ 1 ┆ false │ │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ │ 14 ┆ Kakuna ┆ Bug ┆ Poison ┆ 205 ┆ 45 ┆ 25 ┆ 50 ┆ 25 ┆ 25 ┆ 35 ┆ 1 ┆ false │ │ 129 ┆ Magikarp ┆ Water ┆ null ┆ 200 ┆ 20 ┆ 10 ┆ 55 ┆ 15 ┆ 20 ┆ 80 ┆ 1 ┆ false │ │ 10 ┆ Caterpie ┆ Bug ┆ null ┆ 195 ┆ 45 ┆ 30 ┆ 35 ┆ 20 ┆ 20 ┆ 45 ┆ 1 ┆ false │ │ 13 ┆ Weedle ┆ Bug ┆ Poison ┆ 195 ┆ 40 ┆ 35 ┆ 30 ┆ 20 ┆ 20 ┆ 50 ┆ 1 ┆ false │ └─────┴───────────────────────────┴─────────┴─────────┴───────┴─────┴────────┴─────────┴─────────┴─────────┴───────┴────────────┴───────────┘  I would try to remove this one row like this: df.filter(pl.col("Type 1") != "Dragon" & pl.col("Total") != 600)  but this gives a TypeError: the truth value of an Expr is ambiguous. If we change to .ne() then it runs, but it's removing anything that is a Dragon and removing anything with a Total score of 600 (5 records), when we instead want to remove anything that is BOTH a Dragon and a Total score of 600 (1 record). df.filter(pl.col("Type 1").ne("Dragon") & pl.col("Total").ne(600))  What is the proper way to combine multiple filter conditions like this?

Answer: The error is happening because when you use multiple conditions you need to wrap then in parenthesis. Nevertheless to get rid of that single line the proper way is: df.filter((pl.col("Type 1") != "Dragon") | (pl.col("Total") != 600))  Using a parenthesis over both conditions, and use instead of & the operator | (OR) operator to retain the records that don't meet either of these conditions, you only exclude the records that are both 'Dragon' and have a Total of 600.