Pandas: remove encoding from the string
<p>I have the following data frame:</p>

<pre><code>  str_value
0 Mock%20the%20Week
1 law
2 euro%202016
</code></pre>

<p>There are many such special characters such as <code>%20%</code>, <code>%2520</code>, etc..How do I remove them all. I have tried the following but the dataframe is large and I am not sure how many such different characters are there.</p>

<pre><code>dfSearch['str_value'] = dfSearch['str_value'].str.replace('%2520', ' ')

dfSearch['str_value'] = dfSearch['str_value'].str.replace('%20', ' ')
</code></pre>

<p>You can use the <code>urllib</code> library and apply it using <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.map.html"><code>map</code></a> method of a series.
Example - </p>

<pre><code>In [23]: import urllib

In [24]: dfSearch["str_value"].map(lambda x:urllib.unquote(x).decode('utf8'))
Out[24]:
0    Mock the Week
1              law
2        euro 2016
</code></pre>

python python-2.7 pandas