Pandas.read_csv() with special characters (accents) in column names ï¿½
<p>I have a <code>csv</code> file that contains some data with columns names:</p>

<ul>
<li><em>"PERIODE"</em></li>
<li><em>"IAS_brut"</em></li>
<li><em>"IAS_lissÃ©"</em></li>
<li><em>"Incidence_Sentinelles"</em></li>
</ul>

<p>I have a problem with the third one <strong><em>"IAS_lissÃ©"</em></strong> which is misinterpreted by <code>pd.read_csv()</code> method and returned as ï¿½.</p>

<p>What is that character?</p>

<p>Because it's generating a bug in my flask application, is there a way to read that column in an other way <strong>without modifying the file?</strong></p>

<pre class="lang-py prettyprint-override"><code>In [1]: import pandas as pd

In [2]: pd.read_csv("Openhealth_S-Grippal.csv",delimiter=";").columns

Out[2]: Index([u'PERIODE', u'IAS_brut', u'IAS_lissï¿½', u'Incidence_Sentinelles'], dtype='object')
</code></pre>

<p>You can change the <code>encoding</code> parameter for read_csv, see the pandas doc <a href="http://pandas.pydata.org/pandas-docs/stable/io.html#dealing-with-unicode-data" rel="nofollow">here</a>. Also the python standard encodings are <a href="https://docs.python.org/3/library/codecs.html#standard-encodings" rel="nofollow">here</a>. </p>

<p>I believe for your example you can use the <code>utf-8</code> encoding (assuming that your language is French). </p>

<pre><code>df = pd.read_csv("Openhealth_S-Grippal.csv", delimiter=";", encoding='utf-8')
</code></pre>

<hr>

<p>Here's an example showing some sample output. All I did was make a csv file with one column, using the problem characters.</p>

<pre><code>df = pd.read_csv('sample.csv', encoding='utf-8')
</code></pre>

<p>Output:</p>

<pre><code>    IAS_lissÃ©
0   1
1   2
2   3
</code></pre>

python pandas unicode utf-8 special-characters