Question:

With reference to the parameter header of pd.read_csv(), which of the parameter values allow the column names to be inferred from the first line of csv file?
A. header = 1
B. header = 0
C. header = True
D. header = False

Show Hint

In Pandas, row indexing starts at 0.
Therefore, the first row of a file is represented by index 0.
Setting header=None tells Pandas that the file has no headers, and it assigns default numerical column names.
Updated On: Jun 11, 2026
  • A and D only
  • B and C only
  • B only
  • C only
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation




Step 1: Understanding the Question:

The question asks which value of the header parameter in the pandas.read_csv() function enables Pandas to automatically read and infer column header names from the first line of a CSV file.



Step 2: Key Formula or Approach:

The pd.read_csv() function has a parameter named header.
It accepts integers, list of integers, or None.
By default, header=0, which means the first row (index 0) of the CSV file contains the column names and should be used to infer them.



Step 3: Detailed Explanation:

Let's analyze the parameter choices:
- header=0 (B) is the standard value. Row index 0 (the first line of the file) is parsed as the header, and column names are extracted from it.
- header=1 (A) would imply that row index 1 (the second line of the file) is used as the header, causing the first row of data to be completely ignored.
- Passing boolean values like True (C) or False (D) to the header parameter is syntactically invalid in Pandas and will cause unexpected behavior or raise a TypeError.
Thus, only statement B (header=0) is correct.
This corresponds to option (C) which states "B only".



Step 4: Final Answer:

The correct option is (C), signifying that only statement B is correct.
Was this answer helpful?
0
0