Solve pandas read excel cell error _x0000_

Solution

If the question has been read out, then the only replacealternative is to use:

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)

problem analysis

This is because when pandas parses excel .xlsxfiles, the engine used is openpyxl, and in some cases, due to the modification of excel files, some encoding formats are left in the excel cells, which will cause accidents when using openpyxl

Guess you like

Origin blog.csdn.net/weixin_35757704/article/details/132561696