我有一个Excel表格,其中某些值的字符损坏了
样本:
Email Name
sample@gmail.com Sample Name
sample2@gmail.com игорь
from ftfy import fix_encoding
import pandas as pd
def FixExcelFile():
filepath = fd.askopenfilename(filetypes=[("Excel Files", "*.xlsx")])
if filepath:
xlsx = pd.ExcelFile(filepath)
sheet_name = xlsx.sheet_names[0]
sheet = xlsx.parse(sheet_name)
name_values = sheet['Name'].values
for idx, value in enumerate(name_values):
if isinstance(value, str):
fixedvalue = fix_encoding(value)
if fixedvalue != value:
print(value + " --> " + fixedvalue)
控制台输出为
игорь Ñ€ --> игорь
我现在的问题是,如何替换电子表格本身中的值?