Chapter 2 · Section 1 practice

DataFrames and the First Look

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. Table dimensions

Warm-up. Print the number of rows and columns separately.

Write your answer, then run it.

2. Column labels

Warm-up. Print the column labels as a Python list.

Write your answer, then run it.

3. First observations

Warm-up. Print the first two rows.

Write your answer, then run it.

4. Last observation

Build your skills. Print the final row.

Write your answer, then run it.

5. A column type

Build your skills. Print the dtype of the Units column.

Write your answer, then run it.

6. Series or table

Build your skills. Print the type names of df[“Units”] and df[[“Units”]].

Write your answer, then run it.

7. Named row labels

Build your skills. Print the index labels as a list. Explain how they differ from positions 0–3.

Write your answer, then run it.

8. Numeric text

Challenge. Convert SalesText into a numerical column and print its total.

Write your answer, then run it.

9. Load the course CSV

Challenge. Load the retail CSV using OrderID as its index. Print its shape and first index label.

Write your answer, then run it.

10. Inspect before calculating

Challenge. Create a two-row DataFrame with Store and Sales columns. Print its dimensions and total sales. Use stores Central/Kowloon and sales 120/80.

Write your answer, then run it.

Reference answers are locked until all 10 attempts are submitted.