0
0
Data Analysis Pythondata~10 mins

Exporting to CSV in Data Analysis Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A'data.json'
B'data.csv'
C'data.txt'
D'data.xlsx'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the filename.
Using the wrong file extension.
2fill in blank
medium

Complete 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'
Asep
Bcolumns
Cheader
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using header=False instead of index=False.
Not including the parameter at all.
3fill in blank
hard

Fix 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'
AName, Age
B'Name, Age'
C['Name', 'Age']
D('Name', 'Age')
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string instead of a list.
Using parentheses instead of square brackets.
4fill in blank
hard

Fill 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'
A'output.csv'
B';'
C','
D'output.txt'
Attempts:
3 left
💡 Hint
Common Mistakes
Using comma ',' as separator instead of semicolon ';'.
Wrong filename extension.
5fill in blank
hard

Fill 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'
A'records.csv'
B['ID', 'Score']
C'\t'
D'data.csv'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong separator like comma instead of tab.
Not passing columns as a list.