Creating DataFrames
With a SparkSession, applications can create DataFrames from an existing RDD, from a Hive table, or from Spark data sources.
As an example, the following creates a DataFrame based on the content of a JSON file:
1
val df = spark.read.json("file:///home/dv6/spark/spark/examples/src/main/resources/people.json")
2
df.show()
3
/*
4
+----+-------+
5
| age| name|
6
+----+-------+
7
|null|Michael|
8
| 30| Andy|
9
| 19| Justin|
10
+----+-------+
11
​
12
*/
Copied!
Last modified 1yr ago
Copy link