Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to export the DataFrame to a CSV file named 'data.csv'.
Data Analysis Python
df.to_csv([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the filename.
Using the wrong file extension.
✗ Incorrect
The to_csv method requires the filename as a string. 'data.csv' is the correct filename for CSV export.
2fill in blank
mediumComplete the code to export the DataFrame without the index column.
Data Analysis Python
df.to_csv('data.csv', [1]=False)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using header=False instead of index=False.
Not including the parameter at all.
✗ Incorrect
Setting index=False tells pandas not to write row numbers to the CSV file.
3fill in blank
hardFix the error in the code to export only the 'Name' and 'Age' columns to CSV.
Data Analysis Python
df.to_csv('data.csv', columns=[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string instead of a list.
Using parentheses instead of square brackets.
✗ Incorrect
The columns parameter expects a list of column names, so use ['Name', 'Age'].
4fill in blank
hardFill both blanks to export the DataFrame to 'output.csv' using a semicolon as separator and without the header row.
Data Analysis Python
df.to_csv([1], sep=[2], header=False)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using comma ',' as separator instead of semicolon ';'.
Wrong filename extension.
✗ Incorrect
The filename should be 'output.csv' and the separator for semicolon is ';'.
5fill in blank
hardFill all three blanks to export the DataFrame to 'records.csv', include only 'ID' and 'Score' columns, and use tab as separator.
Data Analysis Python
df.to_csv([1], columns=[2], sep=[3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong separator like comma instead of tab.
Not passing columns as a list.
✗ Incorrect
Use 'records.csv' as filename, list ['ID', 'Score'] for columns, and '\t' for tab separator.