# Combining Conditions with &, | and ~

Python's and, or and not can't combine whole columns of True and False, so pandas uses & (and), | (or) and ~ (not), with parentheses around each comparison; isin, between and str.contains replace long chains of conditions, and query writes a filter as text.

![Cheat sheet: Combining Conditions with &, | and ~](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/403c87de73fc4371aeb0d465ff7cea6d.webp)

- Category: Data Analysis
- Level: Apprentice
- Tags: between(), Boolean Mask, isin(), Logical Operators (python), python
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/pandas-combining-conditions-cheat-sheet
