Chapter 2 · Section 2 practice

Selecting Columns, Rows, and Cells

Work from question 1 to 10. Edit your Python box, click Run Code, review the result, then click Submit attempt. Reference answers unlock after all ten attempts are submitted. This records completion, not correctness. Each box runs independently. Progress is saved in this browser.

Submitted: 0 / 10

1. Select a Series

Warm-up. Print the Units column as a Series.

Write your answer, then run it.

2. Select two columns

Warm-up. Print a DataFrame containing Store and Price.

Write your answer, then run it.

3. A positional slice

Warm-up. Print labels selected by positions 1:3.

Write your answer, then run it.

4. A label slice

Build your skills. Print labels selected by B:D.

Write your answer, then run it.

5. A single cell

Build your skills. Print the price of row C using loc.

Write your answer, then run it.

6. Quantity threshold

Build your skills. Print the labels of orders with at least three units.

Write your answer, then run it.

7. Two conditions

Build your skills. Print Units and Price for Central orders with at least two units.

Write your answer, then run it.

8. Either condition

Challenge. Print the labels of orders with Price >= 100 OR Units >= 4.

Write your answer, then run it.

9. Membership and ranges

Challenge. Keep Central rows whose Units lie between 2 and 4 inclusive. Print their labels.

Write your answer, then run it.

10. Update a separate result

Challenge. Copy df, reduce prices by 10 for Kowloon rows, then print the new prices and the original prices as lists.

Write your answer, then run it.

Reference answers are locked until all 10 attempts are submitted.