Skip to main contentSkip to solution

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

Solution

✅ Correct Option: 3

header=0 tells pandas that row 0, the first line of the file, holds the column names. This is also what the default header='infer' does when no names are passed.


Option A (header=1): uses the second line as the column names and discards the line above it.

Options C and D (header=True, header=False): pandas does not accept a boolean for header and raises an error. To say the file has no header row, use header=None.

Keyboard Shortcuts

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