Learn
Creating, Loading, and Selecting Data with Pandas
Select Rows with Logic III
Suppose we want to select the rows where the customer’s name is either “Martha Jones”, “Rose Tyler” or “Amy Pond”.
name | address | phone | age |
---|---|---|---|
Martha Jones | 123 Main St. | 234-567-8910 | 28 |
Rose Tyler | 456 Maple Ave. | 212-867-5309 | 22 |
Donna Noble | 789 Broadway | 949-123-4567 | 35 |
Amy Pond | 98 West End Ave. | 646-555-1234 | 29 |
Clara Oswald | 54 Columbus Ave. | 714-225-1957 | 31 |
… | … | … | … |
We could use the isin
command to check that df.name
is one of a list of values:
df[df.name.isin(['Martha Jones', 'Rose Tyler', 'Amy Pond'])]
Instructions
1.
Another doctor thinks that you have a lot of clinic visits in the late Winter.
Create the variable january_february_march
, containing the data from January, February, and March. Do this using a single logical statement with the isin
command.
2.
Inspect january_february_march
using print
.