Databricks Certified Machine Learning Associate · Free Practice Question Medium

Question 5

What is the potential reason for the reduced performance speed when using the pandas API compared to native Spark DataFrames, especially for large datasets?

Choose only ONE best answer.


  • A

    The employment of an internalFrame to maintain metadata

  • B

    The requirement for an increased amount of code

  • C

    The dependence on CSV files

  • D

    The immediate evaluation of all processing operations

  • E

    The absence of data distribution

Reveal correct answer

Correct answer: A

Explanation

Correct Answer:
The employment of an internalFrame to maintain metadata

Explanation:

The pandas API on Spark (Koalas) introduces an internalFrame layer to bridge pandas-like operations with Spark's distributed execution. While this enables familiar syntax, it adds overhead due to:

  1. Metadata Management:

    • The internalFrame tracks pandas-like indices, column names, and data types, requiring extra bookkeeping.

  2. Conversion Costs:

    • Pandas operations are translated to Spark plans via this layer, which can slow down execution compared to native Spark DataFrames.

Example Impact:

Why Other Options Are Incorrect:

  1. "Increased code amount":

    • Irrelevant; performance is about execution, not code volume.

  2. "Dependence on CSV files":

    • Unrelated; data source format doesn’t affect API performance.

  3. "Immediate evaluation":

    • Both APIs use lazy evaluation.

  4. "Absence of data distribution":

    • False; pandas API on Spark does distribute data (unlike vanilla pandas).

Key Takeaway:

For large datasets, prefer native Spark DataFrames when:
✅ Performance is critical (avoid internalFrame overhead).
✅ Advanced Spark optimizations (e.g., predicate pushdown) are needed.

Use pandas API on Spark for:
✅ Pandas familiarity on small-to-medium distributed data.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need