Week 3 • Tuesday

Block 23: Selecting Rows & Columns

Access subsets of a DataFrame with loc, iloc, and column selection.

Concepts

Code Examples

See exercise below.

Exercise

Select only numeric columns from the Iris dataset. Use loc to get rows where species == 'setosa' and only the petal columns.

Homework

What is the key difference between loc and iloc? When would each be confusing?