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

后端 未结 11 1089
孤城傲影
孤城傲影 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:13

    spark.range(0).drop("id")
    

    This creates a DataFrame with an "id" column and no rows then drops the "id" column, leaving you with a truly empty DataFrame.

提交回复
热议问题