Joining Table and API Data Sources with Python
A data analyst needs to join together a table data source and web API data source using Python. Which of the following is the best way to accomplish this task?
Community Insight
The question tests knowledge of intermediate data interchange formats for data acquisition; the trap is picking a flat text format (TXT, varchar, or string) that discards the structure needed to align columns before merging.
This DA0-002 question asks how to best combine a table data source with a web API data source in Python. The correct approach is to normalize both sources into JSON, load them as pandas DataFrames, and merge the resulting DataFrames.
Option C (TXT) is the most tempting wrong pick because plain text feels like a universal format, but TXT flattens nested API and table structures, so column keys are lost and a meaningful pandas merge becomes impossible.
Community Discussion (1 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
JSON is the natural interchange format for this task because REST web APIs almost universally return JSON, and SQL/table results can be serialized to JSON without loss of keys, types, or nesting. Once both sources are expressed as JSON documents, json_normalize or pd.read_json turns each into a pandas DataFrame with named columns, after which df1.merge(df2, on=key) joins them cleanly. This preserves the schema alignment that a merge operation depends on. Amelia233 made the same point, noting that "JSON is the best choice because web APIs commonly return data in JSON format."Why the Other Options Are Wrong
Option A's varchar format is a database storage type, not an exchange format, and casting API payloads to varchar would erase structure before the DataFrame is built. Option C's TXT format stores unstructured plain text with no column delimiters guaranteed, so pandas cannot reliably reconstruct matching schemas for a merge. Option D's generic string format has the same defect — a raw Python string carries no field names, so there is nothing to join on once it becomes a DataFrame.Community Comment Notes
The single community comment supports option B and correctly explains that "Python/pandas can easily convert JSON data into DataFrames" before using merge. The commenter's reasoning about web APIs returning JSON matches real API behavior, and no dissenting comments were posted, so the discussion aligns with the technical analysis here.Official Reference
Exam Strategy
When a question asks you to join sources of different types, look for the option that preserves structure and column names through the intermediate step — JSON is the standard answer for API-related joins in DA0-002. Eliminate any option naming a storage-only type (varchar) or an unstructured format (TXT, plain string) before comparing the rest.
Frequently Asked Questions
Why is JSON preferred over TXT or a string format when joining API and table data?
JSON keeps field names and types intact, so both sources produce DataFrames with matching columns. TXT and plain strings flatten the data, destroying the keys a merge needs.
Why isn't varchar the right choice for combining an API with a database table?
varchar is a SQL column storage type, not an interchange format for Python. Casting API responses to varchar strips structure before pandas can build a usable DataFrame.
Related Analysis
Practice All DA0-002 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DA0-002 Practice Test →