1. Home
  2. Data Science
  3. Pandas
  4. For a DataFrame with 200 rows and 6 columns, what does…

Added 30 Nov -0001

For a DataFrame with 200 rows and 6 columns, what does df.shape return?

  1. The column names as an Index object
  2. (200, 6), a tuple of rows then columns Correct answer
  3. (6, 200), a tuple of columns then rows
  4. 1200, the total number of values stored

Correct answer

B. (200, 6), a tuple of rows then columns

16 views

MCQSEXAM

Explanation

shape returns a tuple in the order rows first, then columns, so the answer is (200, 6). It is an attribute rather than a method, so it is written without parentheses, unlike len(df), which returns only the row count. Confusing the order leads to wrong loops when iterating with df.shape[0] for rows and df.shape[1] for columns.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? 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