D9 Lab+Day+9
D9 Lab+Day+9
D9 Lab+Day+9
Found 1 items
hadoopuser@hadoopuser-VirtualBox:~$ spark-shell
scala> sc.setLogLevel("ERROR")
scala> storeDF.collect
OR
scala> storeDF.show(5)
+-----------+-----+---------+
| city|state| zip_code|
+-----------+-----+---------+
| Antioch| CA|945097911|
| Woodland| CA|957765409|
|Victorville| CA|923954216|
| Chico| CA|959284422|
+-----------+-----+---------+
only showing top 5 rows
scala> storeDF.schema
res3: org.apache.spark.sql.types.StructType =
StructType(StructField(city,StringType,true),
StructField(state,StringType,true), StructField(zip_code,LongType,true))
import org.apache.spark.sql.types.Metadata
manualSchema: org.apache.spark.sql.types.StructType =
StructType(StructField(city,StringType,true),
StructField(state,StringType,true), StructField(zip_code,LongType,true))
scala> storeDF.show(5)
+-----------+-----+---------+
| city|state| zip_code|
+-----------+-----+---------+
| Antioch| CA|945097911|
| Woodland| CA|957765409|
|Victorville| CA|923954216|
| Chico| CA|959284422|
+-----------+-----+---------+
scala> storeDF.columns
scala> storeDF.col("city")
scala> storeDF.take(5)
scala> storeDF.collect()
scala> storeDF.show()
+----------------+-----+---------+
| city|state| zip_code|
+----------------+-----+---------+
| Antioch| CA|945097911|
| Woodland| CA|957765409|
| Victorville| CA|923954216|
| Chico| CA|959284422|
| Visalia| CA|932779527|
| Manteca| CA|953366745|
| Lakewood| CA|907122409|
| Hayward| CA|945455008|
| Pacoima| CA|913312352|
| El Centro| CA|922431323|
| Tustin| CA|927828918|
+----------------+-----+---------+
scala> storeDF.first
# to see all
scala> storeDF.show(storeDF.count().toInt)
+-------------------+-----+---------+
| city|state| zip_code|
+-------------------+-----+---------+
| Antioch| CA|945097911|
| Woodland| CA|957765409|
| Victorville| CA|923954216|