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 _____________.
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.
Related questions:
2025: 21 May Shift 1
2025: 21 May Shift 1
2026: 21 May Shift 1
2025: 15 May Shift 2