🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Sorting deletes the index
  2. B.Sorting keeps the original index labels, so labels no longer match positions
  3. C.iloc stops working after sorting
  4. 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 →