Jupter使用pandas导入csv报错, 'gbk' codec can't decode byte 0x81 in position 20: illegal multibyte sequence

时间:2021-08-07 18:11:57
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_csv("E:/Project/Python/Jupyter/NeteaseCouldClass/地市级党委书记数据库(2000-10)1.csv", encoding='gbk',engine = 'python')

然后运行报错

‘gbk’ codec can’t decode byte 0x81 in position 20: illegal multibyte sequence

其实是csv文件本身的错,在另存为csv时,应选择csv(逗号分隔),而不是csv utf-8(逗号分隔)
Jupter使用pandas导入csv报错, 'gbk' codec can't decode byte 0x81 in position 20: illegal multibyte sequence

其实把encoding换成uft-8也可以导入成功,只是导入的数据好像有问题,所以还是不行