Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Illegal start of simple expression creating a simple dataframe in spark

Apologies this is probably something very obvious. I don’t understand why this isn’t working:

val df = spark.createDataFrame([("A",1),("B",2),("C",3)],["Letter","Number"])

When I run this I get the below error:

error: illegal start of simple expression

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Why isn’t this working?

>Solution :

This is Pyspark syntax not Spark Scala. Try this instead:

val df = spark.createDataFrame(Seq(("A",1),("B",2),("C",3))).toDF("Letter", "Number")

Or:

import spark.implicits._

val df = Seq(("A",1),("B",2),("C",3)).toDF("Letter", "Number")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading