Pandas dataframe replace
<p>New to Pandas and python and have a question on replacing multiple unicode characters within an entire data frame.  Using python 2.7 and importing from an excel sheet.  My desire is to replace all non-ascii characters with their ascii equivalent or nothing.</p>

<p>examples:<br>
u'SHOGUN JAPANESE \u2013 GRAND'<br>
u'COMFORT INN &amp; SUITES\xa0STONE MOUNTAIN'</p>

<p>This works, but is cumbersome:  </p>

<pre><code>rawdf = rawdf["Account_Name"].str.upper().str.replace(u'\u2013', ' ').str.replace(u'\xa0', '-') + "|" + rawdf["COID"].str.upper()
</code></pre>

<p>This did not work:</p>

<pre><code>rawdf = rawdf.replace(u'\u2013', ' ')
</code></pre>

<p>You can do an encode/decode cycle like so:</p>

<pre><code>rawdf["Account_Name"].str..encode('ascii', 'ignore').str.decode('ascii')
</code></pre>

<p>The use of 'ignore' makes characters that cannot be represented in ascii be dropped. The intermediate representation is bytes, so we need to encode it back to strings again.</p>

python