1. Home
  2. Data Science
  3. Pandas
  4. How do loc and iloc differ in pandas?

Added 30 Nov -0001

How do loc and iloc differ in pandas?

  1. loc works only on Series objects
  2. iloc works only on numeric columns
  3. loc uses labels; iloc uses positions Correct answer
  4. loc uses positions; iloc uses labels

Correct answer

C. loc uses labels; iloc uses positions

12 views

MCQSEXAM

Explanation

loc indexes by label, with inclusive slice endpoints, whereas iloc indexes by integer position.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Pandas MCQs

Practise all Pandas MCQs

Similar MCQs