DataFrame.count() is used to display the total number of values or row of a DataFrame. To count rows we need to use argument ______.
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
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).
Related questions:
2026: 13 May Shift 2
2026: 18 May Shift 2
2025: 16 May Shift 1