title: PySpark -- Convert List of Rows to Data Frame
body: <p>The problem I'm <em>actually</em> trying to solve is to take the first/last N rows of a PySpark dataframe and have the result be a dataframe. Specifically, I want to be able to do something like this:</p>
  
  <pre><code> my_df.head(20).toPandas()
  </code></pre>
  
  <p>However, because <code>head()</code> returns a list of rows, I get this error:</p>
  
  <pre><code>AttributeError: 'list' object has no attribute 'toPandas'
  </code></pre>
  
  <p>So, I'm looking either for method that will return the first N rows of PySpark dataframe <em>as a dataframe</em>, or a method for converting these lists of rows into a dataframe. Any ideas?</p>