Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Construct Simple Spark DataFrames Using Seq

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

https://medium.com/mrpowers/manually-creating-spark-dataframes-b14dae906393

Seq.toDF

toDF() provides a concise syntax for creating DataFrames and can be accessed after importing Spark implicits.

import spark.implicits._

SparkSession.createDataFrame

Loading...
Loading...
org.apache.spark.sql.SparkSession$implicits$@2d2d2d87
[Number: int, Words: string]
+------+-----+
|Number|Words|
+------+-----+
|     8|  bat|
|    64|mouse|
|   -27|horse|
+------+-----+

root
 |-- Number: integer (nullable = false)
 |-- Words: string (nullable = true)

null
[number: int, word: string]

createDF() is defined in spark-daria and allows for the following terse syntax.

input is incomplete