title: How to create an empty DataFrame? Why "ValueError: RDD is empty"?
body: <p>I am trying to create an empty dataframe in Spark (Pyspark).</p>
  
  <p>I am using similar approach to the one discussed here <a href="https://stackoverflow.com/questions/31477598/how-to-create-an-empty-dataframe">enter link description here</a>, but it is not working.</p>
  
  <p>This is my code</p>
  
  <pre><code>df = sqlContext.createDataFrame(sc.emptyRDD(), schema)
  </code></pre>
  
  <p>This is the error</p>
  
  <pre><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/Users/Me/Desktop/spark-1.5.1-bin-hadoop2.6/python/pyspark/sql/context.py", line 404, in createDataFrame
  rdd, schema = self._createFromRDD(data, schema, samplingRatio)
  File "/Users/Me/Desktop/spark-1.5.1-bin-hadoop2.6/python/pyspark/sql/context.py", line 285, in _createFromRDD
  struct = self._inferSchema(rdd, samplingRatio)
  File "/Users/Me/Desktop/spark-1.5.1-bin-hadoop2.6/python/pyspark/sql/context.py", line 229, in _inferSchema
  first = rdd.first()
  File "/Users/Me/Desktop/spark-1.5.1-bin-hadoop2.6/python/pyspark/rdd.py", line 1320, in first
  raise ValueError("RDD is empty")
  ValueError: RDD is empty
  </code></pre>