Skip to course content
Free course

Python Foundations / Module 9 / Selecting Rows and Columns Deliberately

Module 9 lesson

Selecting Rows and Columns Deliberately

Unit ID: M09-U02 Estimated active time: 25-35 minutes

Use column labels for meaning and Boolean conditions for row rules.

identity = working[["learner_id", "module_id"]]
completed = working.loc[working["status"] == "complete", ["learner_id", "module_id", "score"]]
first_three = working.iloc[:3]

.loc uses labels and conditions. .iloc uses integer positions. Prefer .loc when the task rule names fields.

Parenthesise combined conditions and use & or |, not Python's scalar and or or.

Practice: select valid completed records with at least 45 minutes, keeping only learner, module, minutes, and score.