Question:easy

attribute name is used to display a NumPy ndarray having all the values in the DataFrame, without the axes labels.

Show Hint

Look for the attribute that returns an ndarray, not labels, an int or a tuple.
Updated On: Oct 1, 2026
  • DataFrame.columns
  • DataFrame.size
  • DataFrame.shape
  • DataFrame.values
Show Solution

The Correct Option is D

Solution and Explanation

Step 1: List what each attribute returns.
columns gives an Index of column names. size gives an integer. shape gives a tuple. values gives an ndarray. The question asks for an ndarray, so look at the return type first.

Step 2: Use the return type to cut options.
Only one of the four returns a NumPy ndarray. The other three return an Index object, an int and a tuple. So options 1, 2 and 3 cannot match, whatever their other details are.

Step 3: Use the second clue.
The question also says without the axes labels. The values attribute holds only the cell data. Row and column labels are left out of it.

Step 4: Test it by running code.
import pandas as pd
df = pd.DataFrame({'a':[1,2],'b':[3,4]}, index=['x','y'])
print(df.columns)
print(df.size)
print(df.shape)
print(df.values)
The four prints show Index(['a', 'b']), then 4, then (2, 2), then a 2D array [[1 3] [2 4]]. Only the last line is an array of plain values.

Step 5: Pick the answer.
The attribute is DataFrame.values, option 4.

Step 6: Extra check.
Remember the small rule for pandas attributes. Attributes are used without brackets, so df.values is correct and df.values() would fail. Values is also the one to use when a NumPy function needs the raw numbers of a table. This confirms why the question points to it.

Final Answer:
The attribute that returns the values as an ndarray is DataFrame.values, option 4. \[ \boxed{\text{Option 4: DataFrame.values}} \]
Was this answer helpful?
0


Questions Asked in CUET (UG) exam