Recall & Review
beginner
What is the purpose of exporting data to JSON format?
Exporting data to JSON allows you to save data in a simple, text-based format that is easy to share and use in many applications, especially for web and data exchange.
Click to reveal answer
beginner
Which Python library is commonly used to export data to JSON?
The
pandas library is commonly used to export data frames to JSON using the to_json() method.Click to reveal answer
intermediate
What does the
orient parameter in to_json() control?The
orient parameter controls the format of the JSON output, such as 'records', 'split', 'index', or 'columns', affecting how data is structured in the JSON file.Click to reveal answer
beginner
How do you export a pandas DataFrame named
df to a JSON file called data.json?Use
df.to_json('data.json') to save the DataFrame as a JSON file named data.json in the current folder.Click to reveal answer
intermediate
Why might you choose the 'records' orient when exporting to JSON?
The 'records' orient exports each row as a separate JSON object in a list, which is easy to read and commonly used for APIs and data exchange.
Click to reveal answer
Which method is used to export a pandas DataFrame to JSON?
✗ Incorrect
The
to_json() method is used to export pandas DataFrames to JSON format.What type of file is JSON?
✗ Incorrect
JSON is a text-based file format used to store and exchange data.
Which
orient option exports JSON as a list of row objects?✗ Incorrect
The 'records' orient exports each row as a separate JSON object in a list.
What happens if you call
df.to_json() without a file path?✗ Incorrect
Without a file path,
to_json() returns the JSON data as a string.Why is JSON a popular format for data exchange?
✗ Incorrect
JSON is easy to read and supported by many programming languages and tools.
Explain how to export a pandas DataFrame to a JSON file and describe the role of the 'orient' parameter.
Think about how you save data and how you can change the shape of the JSON output.
You got /4 concepts.
Describe why JSON is useful for sharing data and how it compares to other formats like CSV.
Consider how data looks and what kinds of data structures each format can handle.
You got /4 concepts.