title: How to set display precision in PySpark Dataframe show
body: <p>How do you set the display precision in PySpark when calling <code>.show()</code>?</p>
  
  <p>Consider the following example:</p>
  
  <pre class="lang-python prettyprint-override"><code>from math import sqrt
  import pyspark.sql.functions as f
  
  data = zip(
      map(lambda x: sqrt(x), range(100, 105)),
      map(lambda x: sqrt(x), range(200, 205))
  )
  df = sqlCtx.createDataFrame(data, ["col1", "col2"])
  df.select([f.avg(c).alias(c) for c in df.columns]).show()
  </code></pre>
  
  <p>Which outputs:</p>
  
  <pre class="lang-python prettyprint-override"><code>#+------------------+------------------+
  #|              col1|              col2|
  #+------------------+------------------+
  #|10.099262230352151|14.212583322380274|
  #+------------------+------------------+
  </code></pre>
  
  <p>How can I change it so that it only displays 3 digits after the decimal point? </p>
  
  <p>Desired output:</p>
  
  <pre class="lang-python prettyprint-override"><code>#+------+------+
  #|  col1|  col2|
  #+------+------+
  #|10.099|14.213|
  #+------+------+
  </code></pre>
  
  <p>This is a PySpark version of <a href="https://stackoverflow.com/questions/45007602/how-setup-spark-sql-show-to-output-different-number-format">this scala question</a>. I'm posting it here because I could not find an answer when searching for PySpark solutions, and I think it can be helpful to others in the future.</p>