title: Error converting RDD row to a dataframe with pyspark
body: <p>I wrote a function that I want to apply to a dataframe, but first I have to convert the dataframe to a RDD to map. Then I print so I can see the result:</p>
  
  <pre><code>x = exploded.rdd.map(lambda x: add_final_score(x.toDF()))
  print(x.take(2))
  </code></pre>
  
  <p>The function add_final_score takes a dataframe, which is why I have to convert x back to a DF before I pass it through. However, it give me this error that toDF is not in the list: </p>
  
  <pre><code>Py4JJavaError                             Traceback (most recent call last)
  &lt;ipython-input-491-11e7b77ecf3f&gt; in &lt;module&gt;()
       42 #                      StructField('segmentName', StringType(), True)])
       43 # x = exploded.rdd.map(lambda y: y.toDf())
  ---&gt; 44 print(x.take(2))
  
  ~/spark-2.3.0-bin-hadoop2.7/python/pyspark/rdd.py in take(self, num)
     1356 
     1357             p = range(partsScanned, min(partsScanned + numPartsToTry, totalParts))
  -&gt; 1358             res = self.context.runJob(self, takeUpToNumLeft, p)
     1359 
     1360             items += res
  
  ~/spark-2.3.0-bin-hadoop2.7/python/pyspark/context.py in runJob(self, rdd, partitionFunc, partitions, allowLocal)
      999         # SparkContext#runJob.
     1000         mappedRDD = rdd.mapPartitions(partitionFunc)
  -&gt; 1001         port = self._jvm.PythonRDD.runJob(self._jsc.sc(), mappedRDD._jrdd, partitions)
     1002         return list(_load_from_socket(port, mappedRDD._jrdd_deserializer))
     1003 
  
  ~/spark-2.3.0-bin-hadoop2.7/python/lib/py4j-0.10.6-src.zip/py4j/java_gateway.py in __call__(self, *args)
     1158         answer = self.gateway_client.send_command(command)
     1159         return_value = get_return_value(
  -&gt; 1160             answer, self.gateway_client, self.target_id, self.name)
     1161 
     1162         for temp_arg in temp_args:
  
  ~/spark-2.3.0-bin-hadoop2.7/python/pyspark/sql/utils.py in deco(*a, **kw)
       61     def deco(*a, **kw):
       62         try:
  ---&gt; 63             return f(*a, **kw)
       64         except py4j.protocol.Py4JJavaError as e:
       65             s = e.java_exception.toString()
  
  ~/spark-2.3.0-bin-hadoop2.7/python/lib/py4j-0.10.6-src.zip/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
      318                 raise Py4JJavaError(
      319                     "An error occurred while calling {0}{1}{2}.\n".
  --&gt; 320                     format(target_id, ".", name), value)
      321             else:
      322                 raise Py4JError(
  
  Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.runJob.
  : org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 78.0 failed 1 times, most recent failure: Lost task 0.0 in stage 78.0 (TID 78, localhost, executor driver): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
    File "/home/lisa/spark-2.3.0-bin-hadoop2.7/python/lib/pyspark.zip/pyspark/sql/types.py", line 1556, in _getattr_
      idx = self.__fields__.index(item)
  ValueError: 'toDF' is not in list
  </code></pre>
  
  <p>What does it mean? What list?</p>