This document shows code to create a Spark DataFrame from Row objects, display the DataFrame, and write it out as a Parquet file. It imports SparkSession to create a Spark instance, imports Row and DataFrame functions from Spark SQL, defines Row objects for passenger data and adds them to a list, creates a DataFrame from the list, displays the DataFrame contents, and writes the single-partition DataFrame to a Parquet file called PassengerData.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2K views
Create A DataFrame
This document shows code to create a Spark DataFrame from Row objects, display the DataFrame, and write it out as a Parquet file. It imports SparkSession to create a Spark instance, imports Row and DataFrame functions from Spark SQL, defines Row objects for passenger data and adds them to a list, creates a DataFrame from the list, displays the DataFrame contents, and writes the single-partition DataFrame to a Parquet file called PassengerData.