between()

noun

say it: “bih-TWEEN” /bɪˈtwin/

A pandas method that checks whether each value falls inside a range, ends included, giving True or False for every row.

What does between() do in pandas?

between() answers True for each value from a low number to a high one, both ends included, and False for a value outside the range or a missing one. It keeps rows in a price range, or finds readings that can't be true.

mid_price = products[products["price"].between(50, 100)]   # $50 to $100, both included
print(len(mid_price))

In a sentence

  • “She used between() to find the temperatures outside -20 to 110 °F.”
  • “between() kept every product priced from $50 to $100.”

Level: Journeyman · More Python terms at this level

Updated