title: How do I convert a pyspark dataframe to spark code text?
body: <p>If I have some dataframe <code>df</code> in pyspark, how do I convert it to dataframe &quot;code&quot; so I can store it directly in my test files?  (without simply writing it out manually)</p>
  <p>I want my <em>output</em> to be text that looks like:</p>
  <pre><code>spark.createDataFrame([(&quot;apple&quot;, &quot;red&quot;, 11), (&quot;pear&quot;, &quot;green&quot;, 12)], [&quot;fruit&quot;, &quot;color&quot;, &quot;weight&quot;])
  </code></pre>
  <p>I'm looking for something similar to <code>dput</code>/<code>datapasta</code> in R.</p>