1.数据
from pyspark import SparkContext, SparkConf, Row
from pyspark.sql import SparkSession
conf=SparkConf().setAppName("test").setMaster("local[*]")
sc=SparkContext(conf=conf)
spark=SparkSession(sc)
# Input data: Each row is a bag of words with a ID.
df1 = spark.createDataFrame([ ("x", 'af'), ("z", 'bjfb'), ("W", 'ckljc') ],
["id1", "word1"])
df2 = sc.parallelize([("x", 'ada'), ("z", 'bb'), ("H", 'cc') ,("A","dd")]) \
.map(lambda x: Row(id2=x[0], word2=x[1])).toDF