What is the difference between label-based .loc and position-based .iloc for selecting data in a DataFrame?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: easy
Interview Round: Other
Overview: Asks how the pandas indexers .loc and .iloc differ when selecting rows and columns from a DataFrame, and when to reach for each one. Tests label versus position indexing, slice endpoints, boolean masks, and the index pitfalls that appear after sorting or filtering.