Pandasdrill

Level 1: Selecting and filtering Exercise 6 of 45 Pro

Ranges with between

A pandas exercise from Pandasdrill. Solve it with a Python editor in your browser running real pandas, and it is checked the moment you submit.

The task

Return the employees with between 3 and 6 years of service, including both 3 and 6.

What this exercise teaches

between(3, 6) is the same as (years >= 3) & (years <= 6). When you combine conditions yourself, wrap each one in parentheses and use & rather than the word and.

A hint if you get stuck

Series.between(low, high) includes both ends by default.

This exercise is part of Pro

Pro unlocks all 45 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.

You create a free account first, so Pro is attached to it.

Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.

Start with the free exercises

More exercises in Selecting and filtering