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
system
Closed
4
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.