nerdexam
CompTIA

DA0-002 · Question #18

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 correct answer is B. Convert the data from the API and database to a JSON format and convert them to pandas. To integrate and join data from disparate sources like a web API and a database using Python, the most effective method involves converting both into a structured format that can be easily processed by data analysis libraries.

Data Acquisition and Preparation

Question

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?

Options

  • AConvert the data from the API and database to a varchar format and convert them to pandas
  • BConvert the data from the API and database to a JSON format and convert them to pandas
  • CConvert the data from the API and database to a TXT format and convert them to pandas
  • DConvert the data from the API and database to a string format and convert them to pandas

How the community answered

(26 responses)
  • A
    4% (1)
  • B
    92% (24)
  • D
    4% (1)

Why each option

To integrate and join data from disparate sources like a web API and a database using Python, the most effective method involves converting both into a structured format that can be easily processed by data analysis libraries.

AConvert the data from the API and database to a varchar format and convert them to pandas

`varchar` is a database data type, not a universal format for data interchange between an API, database, and Python, and converting everything to it before pandas is inefficient and possibly lossy.

BConvert the data from the API and database to a JSON format and convert them to pandasCorrect

Web APIs commonly return data in JSON format, which Python can easily parse into dictionaries or lists. Database query results can also be readily converted into similar Python structures, from which pandas DataFrames can be directly created for efficient joining and manipulation.

CConvert the data from the API and database to a TXT format and convert them to pandas

Converting data to a plain TXT format would strip away structure and metadata, making it difficult to parse correctly into pandas DataFrames, especially for complex or nested data typically found in APIs.

DConvert the data from the API and database to a string format and convert them to pandas

Converting everything to a generic 'string format' would likely lose structural information and would be less efficient for direct conversion into pandas DataFrames compared to a structured format like JSON.

Concept tested: Data integration with Python Pandas

Source: https://pandas.pydata.org/docs/user_guide/io.html#json

Topics

#Data Integration#API Data#Pandas#JSON

Community Discussion

No community discussion yet for this question.

Full DA0-002 Practice