Pandas中将中文得字段改成拼音
下载拼音得插件,我这里用得是
pypinyin
在setting中下载好
import pandas as pd
import pypinyin
yingxiao = pd.read_excel('D:/Pandas/yingxiao.xlsx')
for i in yingxiao['shengfen']:
result = pypinyin.pinyin (i,style=pypinyin.NORMAL)
result_ = [i[0] for i in result]
result2 = result_[0].capitalize() + ' ' + ''.join(result_[1:]).capitalize()
#缩写
#result3 = ''.join([i[0].upper() for i in result_])
yingxiao.replace(i,result2,inplace=True)
print(yingxiao)
改成了: