Spark 创建一个简单的DataFrame示例

scala> val df = sc.parallelize(Seq(
     (0,"cat26",30.9), 
     (1,"cat67",28.5), 
     (2,"cat56",39.6),
     (3,"cat8",35.6))).toDF("Hour", "Category", "Value")

scala> df.show
+----+--------+-----+
|Hour|Category|Value|
+----+--------+-----+
|   0|   cat26| 30.9|
|   1|   cat67| 28.5|
|   2|   cat56| 39.6|
|   3|    cat8| 35.6|
+----+--------+-----+
posted @ 2020-12-29 20:22  船长博客  阅读(335)  评论(0编辑  收藏  举报
永远相信美好的事情即将发生!