UnicodeDecodeError: 'gbk' codec can't decode byte 0xb1 in position 5: illegal multibyte sequence
io = r'C:\data.xls'
df1 = pd.read_excel(open(io,'r'),sheet_name='数据',dtype={'Stkcd':str})

在windows下,使用open(io,'rb')可以避免改报错;
b的意思是 On Windows,'b'appended to the mode opens the file in binary mode, so there are also modes like'rb','wb', and'r+b'.

另外,
dtype={'Stkcd':str} 可以指定相应列的格式


constant007
1 声望1 粉丝

承接数据清洗合并,联系q29997442