spark-sql 发表于 2021-02-24 | 更新于 2021-05-26 | 分类于 python | 阅读次数: 123456789101112131415161718191.rdd转换成dataframe ---->rdd需要时列表或者元组构成的rdd1 = sc.parallelize([('a',1),('b',2)])df = spark.createDataFrame(rdd1)df.show()输出结果:+---+---+| _1| _2|+---+---+| a| 1|| b| 2|+---+---+df.first():Row(_1='a', _2=1)df.printSchema() ===>查看df的列字段类型同pandas的inforoot |-- _1: string (nullable = true) |-- _2: long (nullable = true)