PySpark — UnicodeEncodeError: 'ascii' codec can't encode character
<p>Loading a dataframe with foreign characters (åäö) into Spark using <code>spark.read.csv</code>, with <code>encoding='utf-8'</code> and trying to do a simple show().</p>

<pre><code>&gt;&gt;&gt; df.show()

Traceback (most recent call last):
File "&lt;stdin&gt;", line 1, in &lt;module&gt;
File "/usr/lib/spark/python/pyspark/sql/dataframe.py", line 287, in show
print(self._jdf.showString(n, truncate))
UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffd' in position 579: ordinal not in range(128)
</code></pre>

<p>I figure this is probably related to Python itself but I cannot understand how any of the tricks that are mentioned <a href="https://stackoverflow.com/questions/9942594/unicodeencodeerror-ascii-codec-cant-encode-character-u-xa0-in-position-20">here for example</a> can be applied in the context of PySpark and the show()-function.</p>