How can I write a parquet file using Spark (pyspark)? : <p>I'm pretty new in Spark and I've been trying to convert a Dataframe to a parquet file in Spark but I haven't had success yet. The <a href="http://spark.apache.org/docs/latest/sql-programming-guide.html#parquet-files" rel="noreferrer">documentation</a> says that I can use <strong>write.parquet</strong> function to create the file. However, when I run the script it shows me: <em>AttributeError: 'RDD' object has no attribute 'write'</em></p>

<pre><code>from pyspark import SparkContext
sc = SparkContext("local", "Protob Conversion to Parquet ")

# spark is an existing SparkSession
df = sc.textFile("/temp/proto_temp.csv")

# Displays the content of the DataFrame to stdout
df.write.parquet("/output/proto.parquet")
</code></pre>

<p>Do you know how to make this work?</p>

<p>The spark version that I'm using is Spark 2.0.1 built for Hadoop 2.7.3.</p>
