Skip to main contentSkip to solution

DataFrame.count() is used to display the total number of values or row of a DataFrame. To count rows we need to use argument ______.

Solution

✅ Correct Option: 3

With axis=1, DataFrame.count() works across the columns of each row. It returns the number of non-null values in every row, which is the row-wise count.


Option 4: axis=0 is the default and counts non-null values down each column, so it gives a column-wise count.

Option 1 and Option 2: pandas accepts only 0 / 'index' and 1 / 'columns' for axis, so axis=2 is invalid, and axis=True is not the standard way to specify it.

Memory trick: axis=0 goes down the rows (one result per column), and axis=1 goes across the columns (one result per row).

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question