← NumPy & Pandas learning pathNumPy & Pandas · Module 4 of 10
Selecting and filtering data
Pick the rows and columns you need.
📖 Key ideas
- df["marks"] selects a column; df[["name","marks"]] selects several.
- loc selects by labels; iloc selects by position.
- Filter rows: df[df["marks"] > 80].
- Combine conditions with & and |, using brackets.
- query() offers readable filters: df.query("marks > 80").
💡 Real-life example: loc is finding a house by its name; iloc is finding it by its door number in the row.
locLabel-based selection
ilocPosition-based selection
Boolean filteringRows where condition is True
query()String-based filtering