val spark = SparkSession.builder
.master("local[1]")
.appName("SparkByExamples.com")
.getOrCreate()
val data = Seq(("James","Smith","USA","CA"),
("Michael","Rose","USA","NY"),
("Robert","Williams","USA","CA"),
("Maria","Jones","USA","FL")
)
val columns = Seq("firstname","lastname","country","state")
import spark.implicits._
val df = data.toDF(columns:_*)
df.show(false)
df.select("firstname","lastname").show()
================
val spark = SparkSession.builder
.master("local[1]")
.appName("SparkByExamples.com")
.getOrCreate()
val data = Seq(("James","Smith","USA","CA"),
("Michael","Rose","USA","NY"),
("Robert","Williams","USA","CA"),
("Maria","Jones","USA","FL")
)
val columns = Seq("first name","last # name","coun ? try","sta te")
import spark.implicits._
val df = data.toDF(columns:_*)
df.show(false)
df.select("first name","last # name" , "coun ? try").show()
scala> df.select("first name","last # name" , "coun ? try").show()
+----------+-----------+----------+
|first name|last # name|coun ? try|
+----------+-----------+----------+
| James| Smith| USA|
| Michael| Rose| USA|
| Robert| Williams| USA|
| Maria| Jones| USA|
+----------+-----------+----------+