1. Home
  2. Data Science
  3. Pandas
  4. What does df.head() return by default in pandas?

Added 30 Nov -0001

What does df.head() return by default in pandas?

  1. Five randomly sampled rows
  2. A summary of each column's dtype
  3. The first five rows of the DataFrame Correct answer
  4. The first five columns of the DataFrame

Correct answer

C. The first five rows of the DataFrame

15 views

MCQSEXAM

Explanation

head() returns the first five rows, and passing an integer such as head(10) changes the count; tail() mirrors it from the bottom of the frame. It is a preview method for inspection, so it returns a new DataFrame rather than modifying the original. For a statistical summary of numeric columns you need describe(), and for dtypes you use the dtypes attribute.

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