• Skip to primary navigation
  • Skip to content
  • Skip to footer
Looking for data in all the right places...
  • Portfolio
  • Posts
  • Categories
  • Tags
  • About
    Francis T. O'Donovan

    Francis T. O'Donovan

    Data Scientist – Planet discoverer, researcher, developer, geek.

    • Boston, MA
    • Website
    • Email
    • Bitbucket
    • GitHub
    • Google Scholar
    • KeyBase
    • LinkedIn
    • Medium
    • ORCiD
    • ResearchGate
    • StackOverflow
    • Mastodon
    • Keyoxide

    Pandas: Inverse of boolean

    November 9, 2017 less than 1 minute read

    In pandas, you can use the tilde (~) to flip bool values:

    >>> df = pd.DataFrame({"A": ["Hello", "this", "World", "apple"]})
    >>> df[df.A.str.contains("Hello|World")]
           A
    0   Hello
    2   World
    >>> df[~df.A.str.contains("Hello|World")]
           A
    1   this
    3  apple
    

    Via Stack Overflow.

    Tags: pandas, til

    Categories: til

    Updated: May 13, 2025

    Share on

    Twitter Facebook LinkedIn
    Previous Next

    Leave a comment

    You may also enjoy

    Using Stoicism to thrive as an IC Data Scientist

    January 25, 2026 6 minute read

    For Data Scientists facing lack of control over data and outcomes, Stoicism offers a framework to thrive in one’s career. By focusing on the “Dichotomy of Co...

    Culture turns strategy into action

    January 22, 2026 2 minute read

    Like many people, I enjoy working at startups with a mission I believe in. These companies match talented individuals with the latest technologies to solve i...

    Python: How uv got so fast

    January 9, 2026 less than 1 minute read

    I love uv, the latest python dependencies manager, and use it whenever I can.

    Stoicism and the pursuit of a good life

    December 17, 2025 2 minute read

    Stoicism emphasizes focusing on the controllable aspects of our lives and accepting the uncontrollable. Applying this philosophy can help us in our pursuit o...

    • Follow:
    • Feed
    © 2026 Francis T. O'Donovan. Powered by Jekyll & Minimal Mistakes.