title: Convert Array[Row] to DataFrame in Spark/Scala
body: <p>I want to convert <code>Array[org.apache.spark.sql.Row]</code> to a <code>DataFrame</code>.
  Could anyone suggest me a better way?</p>
  
  <p>I tried to first convert it into <code>RDD</code> and then tried to convert it into <code>Dataframe</code> , but when I perform any operation on the <code>DataFrame</code> , exceptions are shown.</p>
  
  <pre><code>val arrayOfRows = myDataFrame.collect().map(t =&gt; myfun(t))
  val distDataRDD = sc.parallelize(arrayOfRows)
  val newDataframe = sqlContext.createDataFrame(distDataRDD,myschema)
  </code></pre>
  
  <p>Here <code>myfun()</code> is a function which returns <code>Row (org.apache.spark.sql.Row)</code>.
  The contents in the array is correct and I am able to print it without any problem.</p>
  
  <p>But when I tried to count the records in the <code>RDD</code>, it gave me the count as well as a warning that one of the stage contains a task of very large size.I guess I am doing something wrong. Please help. </p>