Skip to main content

Filtering data

Filtering is used to restrict the data you are processing

Filter by an attribute

  1. Here is an example filter by a string attribute and equality operator

    for flight in flights
    filter flight.TailNum == 'N592ML'
    return flight
  2. Here is an example filter by a integer attribute and > operator

    for flight in flights
    filter flight.Distance > 600
    return flight
  3. You can also create compound/composite conditions

    for flight in flights
    filter flight.Distance > 600
    filter flight.TailNum == 'N592ML'
    return flight
  4. The query above is exactly the same as a composite AND

    for flight in flights
    filter flight.Distance > 600 and flight.TailNum == 'N592ML'
    return flight
  5. The query above is NOT the same as the as query with OR

    for flight in flights
    filter flight.Distance > 600 or flight.TailNum == 'N592ML'
    return flight
 
Help us improve

Anything unclear or buggy in this tutorial? Provide Feedback