Scala Seq创建简单的Spark DataFrame
val goalsDF = Seq( ("messi", 2), ("messi", 1), ("pele", 3), ("pele", 1) ).toDF("name", "goals") goalsDF.show() +-----+-----+ | name|goals| +-----+-----+ |messi| 2| |messi| 1| | pele| 3| | pele| 1| +-----+-----+
val goalsDF = Seq( ("messi", 2), ("messi", 1), ("pele", 3), ("pele", 1) ).toDF("name", "goals") goalsDF.show() +-----+-----+ | name|goals| +-----+-----+ |messi| 2| |messi| 1| | pele| 3| | pele| 1| +-----+-----+