DA0-002 practice question 8 of 25
[Data Acquisition and Preparation]A data analyst needs to join together a table data source and a web API data source using Python. Which of the…
Full set: 111 questions[Data Acquisition and Preparation]
A data analyst needs to join together a table data source and a web API data source using Python. Which of the following is the best way to accomplish this task?
The most efficient and standard method for this task is to work with structured data formats that Python's data analysis libraries, like pandas, are optimized for. Web APIs commonly return data in JSON (JavaScript Object Notation) format. This structured format can be directly and easily parsed into a pandas DataFrame, preserving data types and relationships. Similarly, data queried from a database can be loaded directly into a DataFrame. Once both data sources are represented as DataFrames, pandas provides powerful and optimized merge or join functions to combine them based on common keys. This approach minimizes intermediate conversion steps and avoids the loss of data type information.
A. varchar is a database-specific data type, not a universal data interchange format. Converting all data to this string-like type would unnecessarily discard valuable numeric and date-type information.
C. Converting structured API and database data to a flat TXT file is an inefficient intermediate step that adds complexity and risks data integrity issues during parsing.
D. Converting all data to a generic string format is a poor practice as it loses essential data type information (e.g., integers, floats), making subsequent numerical analysis and joins difficult.
1. Pandas Official Documentation
IO Tools (JSON): The documentation explicitly details the pandas.readjson function for converting a JSON string directly into a pandas DataFrame. This is the standard method for handling API data.
Source: Pandas Development Team. (2023). pandas-docs: IO Tools (Text
CSV
HDF5
…). Section: JSON. Retrieved from https://pandas.pydata.org/pandas-docs/stable/userguide/io.html#json
2. Pandas Official Documentation
IO Tools (SQL): The documentation shows the pandas.readsql function
which is designed to read the result of a SQL query directly into a DataFrame
preserving data types from the database where possible.
Source: Pandas Development Team. (2023). pandas-docs: IO Tools (Text
CSV
HDF5
…). Section: SQL queries. Retrieved from https://pandas.pydata.org/pandas-docs/stable/userguide/io.html#sql-queries
3. University of Illinois Urbana-Champaign
Courseware: In the "Data Visualization" course materials
the standard workflow for handling web data is demonstrated. It involves making an API request
parsing the resulting JSON response
and loading it into a data structure like a pandas DataFrame for analysis.
Source: University of Illinois Urbana-Champaign. (2022). CS 307: Working with APIs and JSON. Week 3 Notes. Retrieved from https://uiuc-ischool-dataviz.github.io/spring2022/week03/workingwithapisandjson.html (Specifically
the section on parsing JSON and creating DataFrames).
Keep practicing
Take the free DA0-002 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other DA0-002 practice questions
- Question 1[Data Analysis]A data analyst learns that a report detailing employee sales is reflecting…
- Question 2[Data Analysis]A data analyst is evaluating all conditions in a query. Which of the follo…
- Question 3[Data Analysis]A data analyst creates a report that identifies the middle 50% of the coll…
- Question 4[Data Governance]Which of the following explains the purpose of UAT?
- Question 5[Data Analysis]A product goes viral on social media, creating high demand. Distribution c…
- Question 6[Data Analysis]A data analyst team needs to segment customers based on customer spending …
