1. A data science team is performing EDA on a PySpark DataFrame `clickstream_df` with 50 million rows. A team member proposes: 'Let's use `pyspark.pandas` (pandas-on-Spark) so we can write familiar Pandas code while keeping data distributed.' A second team member responds: 'We should just call `.toPandas()` and work in native Pandas — it's simpler.' Which statement BEST captures the key trade-off between these two approaches?
- A. Pandas-on-Spark always produces identical results to native Pandas, so the only difference is syntax verbosity.
- B. Calling `.toPandas()` on 50 million rows collects all data to the driver node, risking memory exhaustion, whereas pandas-on-Spark executes operations in a distributed fashion across the cluster.✓ Correct
- C. Pandas-on-Spark requires converting the DataFrame to a Pandas DataFrame internally before each operation, making it slower than native Pandas for large datasets.
- D. Calling `.toPandas()` is preferred for large datasets because native Pandas uses vectorized C operations that are faster than Spark's JVM-based execution.
Explanation
B is correct: `.toPandas()` on 50 million rows forces all data onto the driver node's memory, which is likely to cause OutOfMemoryErrors on a typical driver. Pandas-on-Spark (pyspark.pandas) translates Pandas-style operations into Spark execution plans, keeping data distributed across worker nodes. A is incorrect because pandas-on-Spark does not guarantee identical results in all cases — some behaviors differ (e.g., default index handling, certain API gaps). C is incorrect because pandas-on-Spark does NOT convert data to a Pandas DataFrame before each operation; it submits Spark jobs instead. D is incorrect because while native Pandas is faster for small data due to C vectorization, it is completely impractical for 50 million rows due to driver memory constraints.