Question:easy

In a Pandas DataFrame, which value for axis will be used to delete a column?

Show Hint

In Pandas, axis 0 means rows and axis 1 means columns, so use the axis that points to columns.
Updated On: Oct 20, 2026
  • axis = -1
  • axis = 0
  • axis = 1
  • axis = 2
Show Solution

The Correct Option is C

Solution and Explanation

Step 1: Build a small picture:
Think of a DataFrame as a table. The rows run down the table and the columns run across it.
Pandas numbers these two directions as axis 0 (rows) and axis 1 (columns).

Step 2: See what a drop call needs:
The call df.drop('Age', axis=1) removes the column named Age. The call df.drop(2, axis=0) removes the row labelled 2.
So the axis tells Pandas which set of labels to search.

Step 3: Rule out the wrong values:
axis = 0 would delete a row, so it does not delete a column.
axis = 2 does not exist for a 2D table and gives ValueError.
axis = -1 is not accepted for a DataFrame either. It also gives ValueError: No axis named -1.

Step 4: Pick the answer:
The value that is used to delete a column is axis = 1.

Final Answer:
axis = 1 deletes a column. The answer is option (C).
Was this answer helpful?
0