How to create an empty DataFrame? Why “ValueError: RDD is empty”?

后端 未结 11 1093
孤城傲影
孤城傲影 2021-02-01 03:48

I am trying to create an empty dataframe in Spark (Pyspark).

I am using similar approach to the one discussed here enter link description here, but it is not working.

11条回答
  •  再見小時候
    2021-02-01 04:24

    You can create an empty data frame by using following syntax in pyspark:

    df = spark.createDataFrame([], ["col1", "col2", ...])
    

    where [] represents the empty value for col1 and col2. Then you can register as temp view for your sql queries:

    **df2.createOrReplaceTempView("artist")**
    

提交回复
热议问题