Question:

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
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

Step 1: Understand the question.
We need the DataFrame attribute that gives back only the data as a NumPy ndarray. The row labels and the column labels must not be included.

Step 2: Recall the concept.
A pandas DataFrame stores data with an index (row labels) and columns (column labels). Some attributes return those labels. One attribute strips the labels and returns the plain data array.

Step 3: Check option 1 (DataFrame.columns).
This returns the column labels as an Index object. It gives labels, not the data values. Option 1 is wrong.

Step 4: Check option 2 (DataFrame.size).
This returns one integer: the total count of elements, which is rows multiplied by columns. It is not an array of values. Option 2 is wrong.

Step 5: Check option 3 (DataFrame.shape).
This returns a tuple like (rows, columns). It tells the dimensions only. Option 3 is wrong.

Step 6: Check option 4 (DataFrame.values).
This returns a NumPy ndarray holding all the data without the axis labels. Option 4 is correct.

Step 7: Verify with code.
Run this small program and read the output. For a DataFrame with two rows and two columns, the last line prints only the numbers as a 2D array.
import pandas as pd
df = pd.DataFrame({'a':[1,2],'b':[3,4]}, index=['x','y'])
print(type(df.values))
print(df.values)
The output is a numpy.ndarray with rows [1 3] and [2 4]. No labels are shown.

Final Answer:
DataFrame.values gives the ndarray of values without labels. This is option 4. \[ \boxed{\text{DataFrame.values}} \]
Was this answer helpful?
0
0