Recall & Review
beginner
What is the purpose of exporting data to a CSV file?
Exporting data to a CSV file allows you to save your data in a simple, text-based format that can be easily shared and opened by many programs like Excel or text editors.
Click to reveal answer
beginner
Which Python library is commonly used to export data to CSV files?
The pandas library is commonly used to export data to CSV files using the DataFrame method
to_csv().Click to reveal answer
intermediate
What does the
index=False parameter do in to_csv()?The
index=False parameter tells pandas not to write the row numbers (index) to the CSV file, so only the data columns are saved.Click to reveal answer
intermediate
How can you export only specific columns of a DataFrame to a CSV file?
You can select the columns you want by using
df[['col1', 'col2']].to_csv('file.csv') to export only those columns.Click to reveal answer
intermediate
What is a common delimiter used in CSV files, and can it be changed?
The common delimiter in CSV files is a comma (,), but you can change it using the
sep parameter in to_csv(), for example sep=';' for semicolons.Click to reveal answer
Which pandas method is used to export a DataFrame to a CSV file?
✗ Incorrect
The correct method to export a DataFrame to CSV is
to_csv(). read_csv() is for reading CSV files.What does setting
index=False do when exporting to CSV?✗ Incorrect
Setting
index=False excludes the row numbers (index) from being saved in the CSV file.How do you export only columns 'A' and 'B' from a DataFrame
df to CSV?✗ Incorrect
You select columns first with
df[['A', 'B']] then call to_csv() to export only those columns.What is the default delimiter used by pandas when exporting to CSV?
✗ Incorrect
The default delimiter for CSV files in pandas is a comma (,).
Which parameter changes the delimiter in
to_csv()?✗ Incorrect
The parameter
sep is used to specify a different delimiter in to_csv().Explain how to export a pandas DataFrame to a CSV file without including the index.
Think about the method name and the parameter to exclude row numbers.
You got /5 concepts.
Describe how you would export only certain columns from a DataFrame to a CSV file.
Remember how to pick columns before exporting.
You got /5 concepts.