Skip to main contentSkip to solution

Which of the following is the correct command to read the CSV file "ResultData.csv" separated by ',' , using the pandas library in Python? The file is stored in "C:/NCERT".

Solution

✅ Correct Option: 1

Pandas reads a CSV file with the function pd.read_csv(). Its first argument is the file path, sep sets the separator (here a comma), and header=0 takes the first row as the column names. Option 1 uses all three correctly.


Options 2 and 3: readfromcsv and readtocsv are not pandas functions. The only reader is read_csv, and the writer is to_csv.

Option 3 also sets sep=" ", which is a space, not a comma.

Option 4: load_csv does not exist in pandas, and the parameter is sep (or delimiter), not seperator.

Keyboard Shortcuts

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