解決方法
如果已經(jīng)讀出來了這個問題,那么就只能使用replace
替換了:文章來源:http://www.zghlxwxcb.cn/news/detail-679874.html
import pandas as pd
def change_excel_char(value):
"""剔除讀取excel中的 _x0000_ 字符"""
if type(value) == str:
return value.replace("_x0000_", '')
else:
return value
excel_data = pd.read_excel("xxxx.xlsx")
excel_data = excel_data.applymap(change_excel_char)
問題解析
這是因為pandas解析excel的.xlsx
文件時,使用的引擎是openpyxl,而有些情況下因為excel文件修修改改,導致有些編碼格式被遺留在了excel單元格中,會在使用openpyxl時出現(xiàn)意外文章來源地址http://www.zghlxwxcb.cn/news/detail-679874.html
到了這里,關于解決pandas讀取excel單元格出錯_x0000_的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!