创建一个空的spark dataframe
作者:互联网
from pyspark.sql.types import * from pyspark.sql import SparkSession spark = SparkSession.builder.appName('TEST').getOrCreate() sc=spark.sparkContext schema = StructType([ StructField("a", IntegerType(), True), StructField("b", IntegerType(), True), StructField("c", IntegerType(), True)]) # 通过定义好的dataframe的schema来创建空dataframe df1 = spark.createDataFrame(spark.sparkContext.emptyRDD(), schema) df1.show()
想要创建一个空的spark dataframe,需要先指定schema 的类型
标签:创建,StructField,dataframe,IntegerType,spark,True,schema 来源: https://www.cnblogs.com/augustewsj/p/15479872.html