chi*_*n s 3 python python-2.7 pandas
我有以下数据框:
str_value
0 Mock%20the%20Week
1 law
2 euro%202016
Run Code Online (Sandbox Code Playgroud)
有很多这样的特殊字符,例如%20%,%2520,etc..How我将它们全部删除.我尝试了以下但数据框很大,我不确定有多少这样的不同字符.
dfSearch['str_value'] = dfSearch['str_value'].str.replace('%2520', ' ')
dfSearch['str_value'] = dfSearch['str_value'].str.replace('%20', ' ')
Run Code Online (Sandbox Code Playgroud)
您可以使用该urllib库并使用map系列的方法应用它.示例 -
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
746 次 |
| 最近记录: |