Learn
You can also select multiple rows from a DataFrame.
Here are a few more rows from ShoeFly.com’s orders
DataFrame:
id | first_name | last_name | shoe_type | shoe_material | shoe_color | |
---|---|---|---|---|---|---|
54791 | Rebecca | Lindsay | [email protected] | clogs | faux-leather | black |
53450 | Emily | Joyce | [email protected] | ballet flats | faux-leather | navy |
91987 | Joyce | Waller | [email protected] | sandals | fabric | black |
14437 | Justin | Erickson | [email protected] | clogs | faux-leather | red |
79357 | Andrew | Banks | [email protected] | boots | leather | brown |
52386 | Julie | Marsh | [email protected] | sandals | fabric | black |
20487 | Thomas | Jensen | [email protected] | clogs | fabric | navy |
76971 | Janice | Hicks | [email protected] | clogs | faux-leather | navy |
21586 | Gabriel | Porter | [email protected] | clogs | leather | brown |
Here are some different ways of selecting multiple rows:
orders.iloc[3:7]
would select all rows starting at the 3rd row and up to but not including the 7th row (i.e., the 3rd row, 4th row, 5th row, and 6th row)
id | first_name | last_name | shoe_type | shoe_material | shoe_color | |
---|---|---|---|---|---|---|
14437 | Justin | Erickson | [email protected]ook.com | clogs | faux-leather | red |
79357 | Andrew | Banks | [email protected] | boots | leather | brown |
52386 | Julie | Marsh | [email protected] | sandals | fabric | black |
20487 | Thomas | Jensen | [email protected] | clogs | fabric | navy |
orders.iloc[:4]
would select all rows up to, but not including the 4th row (i.e., the 0th, 1st, 2nd, and 3rd rows)
id | first_name | last_name | shoe_type | shoe_material | shoe_color | |
---|---|---|---|---|---|---|
54791 | Rebecca | Lindsay | [email protected] | clogs | faux-leather | black |
53450 | Emily | Joyce | [email protected] | ballet flats | faux-leather | navy |
91987 | Joyce | Waller | [email protected] | sandals | fabric | black |
14437 | Justin | Erickson | [email protected] | clogs | faux-leather | red |
orders.iloc[-3:]
would select the rows starting at the 3rd to last row and up to and including the final row
id | first_name | last_name | shoe_type | shoe_material | shoe_color | |
---|---|---|---|---|---|---|
20487 | Thomas | Jensen | [email protected] | clogs | fabric | navy |
76971 | Janice | Hicks | [email protected] | clogs | faux-leather | navy |
21586 | Gabriel | Porter | [email protected] | clogs | leather | brown |
Instructions
1.
One of your doctors thinks that there are more clinic visits in the late Spring.
Write a command that will produce a DataFrame made up of the data for April, May, and June from df
for all four sites (rows 3 through 6), and save it to april_may_june
.
2.
Inspect april_may_june
using print
.
Sign up to start coding
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.