Skip to main contentSkip to solution

Which of the following command will display a tuple representing the dimensionality of the DataFrame 'df'?

Solution

✅ Correct Option: 3

df.shape returns a tuple (rows,columns)(\text{rows}, \text{columns}) giving the dimensions of the DataFrame. For example, a DataFrame with 5 rows and 3 columns gives (5, 3).


Option 1: df.values returns the data as a NumPy array, not the dimensions.

Option 2: df.size returns a single integer, the total number of elements (rows x columns), not a tuple.

Option 4: df.empty returns a Boolean (True or False) showing whether the DataFrame has no data.

Keyboard Shortcuts

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