← Quiz: pandas Basics: all 10 questions
Quiz: pandas Basics · Question 7 of 10
Why can loc and iloc give different rows after you sort a DataFrame?
Why can loc and iloc give different rows after you sort a DataFrame?
- A.Sorting deletes the index
- B.Sorting keeps the original index labels, so labels no longer match positions
- C.iloc stops working after sorting
- D.loc only works on unsorted data
Answer & explanation
Correct answer: Sorting keeps the original index labels, so labels no longer match positions
loc uses labels, iloc uses positions.
Can you get the rest right without peeking?
Take the timed Quiz: pandas Basics quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →