Skip to main contentSkip to solution

While transferring the data from a DataFrame to CSV file, if we do not want the row labels to be written to the file on the disk, the parameter to be used in to_csv() is _____________.

Solution

✅ Correct Option: 1

The to_csv() method has an index parameter that controls whether the row labels (the index) are written to the file. Setting index=False leaves them out, so only the column data and column headers are saved.

Example: df.to_csv('data.csv', index=False)


Options 2 and 3: header controls the column labels, not the row labels.

Option 4: index=True is the default, so it writes the row labels.

Keyboard Shortcuts

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