Selection & Filtering
loc vs. iloc, and filtering rows with boolean conditions.
.loc selects by label, .iloc selects by integer position; mixing
them up is one of the most common pandas bugs, especially once your index
isn't the default 0, 1, 2, ….
Combine conditions with &/| (never Python's and/or), and wrap each
condition in parentheses because &/| bind tighter than comparisons.
⚠️ Watch out: df[df.a > 0]['b'] = 1 can silently fail to write back (chained-indexing / SettingWithCopyWarning). Use df.loc[df.a > 0, 'b'] = 1 instead.
Now practice it
Exercises that use what this lesson just covered.