dplyr to pandas: filter(flights, !(arr_delay > 120 | dep_delay > 120))

How can I do filter(flights, !(arr_delay > 120 | dep_delay > 120)) in pandas?

I tried flights[~((flights.arr_delay > 120) | (flights.dep_delay > 120))], which didn't work.

# R
library(dplyr)
library(nycflights13)
filter(flights, !(arr_delay > 120 | dep_delay > 120))
# Python
import pandas as pd
from nycflights13 import flights

Haven't tested. But something like:

flights[~((flights['arr_delay'] > 120) | (flights['dep_delay'] > 120))]

I think of it being much more like the baseR syntax.
No great Python programmer and not a fan - so this may be not be the best way

I much prefer RStudio + R + dplyr

Take a look at suba