如何从列中的值中删除重音符号? [英] How to remove accents from values in columns?

查看:71
本文介绍了如何从列中的值中删除重音符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将特殊字符更改为通常的字母? 这是我的数据框:

How do I change the special characters to the usual alphabet letters? This is my dataframe:

In [56]: cities
Out[56]:

Table Code  Country         Year        City        Value       
240         Åland Islands   2014.0      MARIEHAMN   11437.0 1
240         Åland Islands   2010.0      MARIEHAMN   5829.5  1
240         Albania         2011.0      Durrës      113249.0
240         Albania         2011.0      TIRANA      418495.0
240         Albania         2011.0      Durrës      56511.0 

我希望它看起来像这样:

I want it to look like this:

In [56]: cities
Out[56]:

Table Code  Country         Year        City        Value       
240         Aland Islands   2014.0      MARIEHAMN   11437.0 1
240         Aland Islands   2010.0      MARIEHAMN   5829.5  1
240         Albania         2011.0      Durres      113249.0
240         Albania         2011.0      TIRANA      418495.0
240         Albania         2011.0      Durres      56511.0 

推荐答案

使用以下代码:

df['Country'] = df['Country'].str.replace(u"Å", "A")
df['City'] = df['City'].str.replace(u"ë", "e")

请参见此处!当然,您应该对每个特殊字符和每一列都进行此操作.

See here! Of course you should do it then for every special character and every column.

这篇关于如何从列中的值中删除重音符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆