基礎(chǔ)數(shù)據(jù):
import pandas as pd
import numpy as np
import opencc #繁體簡體互轉(zhuǎn)
data=pd.read_csv('data_test.csv',encoding='gbk')
data.head()
1.安裝opencc-python-reimplemented
pip install opencc-python-reimplemented
2.簡體轉(zhuǎn)繁體,并寫到DataFrame
list_1=[]
for i in range(data.shape[0]):
# t2s - 繁體轉(zhuǎn)簡體
# s2t - 簡體轉(zhuǎn)繁體
op_cc=opencc.OpenCC('s2t')
opc=op_cc.convert(data.loc[i]['出發(fā)地 '])
list_1.append(opc)
#將轉(zhuǎn)化的繁體,寫入到DataFrame
data['出發(fā)地_繁體']=list_1
data
注:參考:https://mbd.baidu.com/newspage/data/landingshare?pageType=1&isBdboxFrom=1&context=%7B%22nid%22%3A%22news_9766458758643458375%22%2C%22sourceFrom%22%3A%22bjh%22%7D