
Explanation:
To convert a PySpark DataFrame to a Pandas DataFrame, you can use the 'toPandas()' method. To convert a Pandas DataFrame to a PySpark DataFrame using Pandas API on Spark, you can use the 'to_spark()' method. The correct code snippet is shown in option C, which demonstrates the conversion between the two DataFrame types using Pandas API on Spark.
Ultimate access to all questions.
No comments yet.
Consider a PySpark DataFrame named 'spark_df' and a Pandas DataFrame named 'pandas_df'. Write a code snippet that demonstrates the conversion between these two DataFrame types using Pandas API on Spark.
A
pandas_df = spark_df.toPandas() spark_df = pandas_df.toSpark()
B
pandas_df = spark_df.toPandasAPI() spark_df = pandas_df.toSparkAPI()
C
pandas_df = spark_df.toPandas() spark_df = pandas_df.to_spark()
D
pandas_df = spark_df.toPandas() spark_df = spark_df.createDataFrame(pandas_df)