1. Home
  2. Data Science
  3. Python
  4. What is the difference between loc and iloc in pandas in…

Added 25 Nov 2026

What is the difference between loc and iloc in pandas in Python?

  1. loc is for columns only
  2. iloc selects by label
  3. They are identical
  4. loc selects by label; iloc selects by integer position Correct answer

Correct answer

D. loc selects by label; iloc selects by integer position

5 views

MCQSEXAM

Explanation

loc uses labels, iloc uses integer positions.

Reference

Asked in: Python Interview Data Libraries

https://docs.python.org/3/library/index.html

Preparing for an exam?

Doubts & discussion

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

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs