Question:

__________ will display the total number of values for each column or row of a DataFrame.

Show Hint

The method that counts non-missing values in each column or row is count().
Updated On: Oct 1, 2026
  • count()
  • tail(n)
  • head(n)
  • max(n)
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Step 1: Understanding the Concept:
The question asks for a DataFrame method that reports how many values are present in each column or each row. Counting values is the job of count(). The axis argument selects columns (axis=0) or rows (axis=1).

Step 2: Check option 1 (count()).
df.count() gives the number of non-NaN values per column. df.count(axis=1) gives it per row. This is what the sentence describes. So option 1 is correct.

Step 3: Check option 2 (tail(n)).
tail(n) shows the last n rows of the DataFrame. It shows data, not a count. So option 2 is wrong.

Step 4: Check option 3 (head(n)).
head(n) shows the first n rows. It shows data, not a count. So option 3 is wrong.

Step 5: Check option 4 (max(n)).
max() gives the largest value in each column, and it does not take a number n for this purpose. It does not count values. So option 4 is wrong.

Step 6: Final Answer:
The method is count(), which is option 1. \[ \boxed{\text{count()}} \]
Was this answer helpful?
0
0