UnicodeDecodeError:“ utf-8”编解码器无法解码位置Pandas中的字节0xfc

问题描述

我正在尝试将df转换为词典列表,但出现Unicode错误

代码:-

df = reduce(lambda df_i,df_j: pd.concat([df_i,df_j]).drop_duplicates(subset=distinct_col),pd.read_csv(csv_filepath,encoding='latin1',engine='python',skipinitialspace=True,skiprows = header_count,usecols=read_col,iterator=True,header=None,names=csv_col_name,chunksize=2,sep='\s*[;]\s*',dtype=str))
                        
df.drop(df.tail(footer_count).index,inplace=True)
#getting error while converting into list of dictionaries..
csv_records=df.to_dict('records')

错误:-

  1. 如果encoding ='latin1',则会出现以下错误: UnicodeEncodeError:“ ascii”编解码器无法在其中编码字符“ \ xfc” 位置85:序数不在范围内(128)_'ascii'编解码器无法编码 位置85的字符'\ xfc':序数不在范围(128)_line 编号:171
  2. 如果encoding ='utf-8',则会出现以下错误: UnicodeDecodeError:“ utf-8”编解码器无法解码字节0xfc 位置860:无效的起始字节 _'utf-8'编解码器无法解码位置860的字节0xfc:无效的起始字节行编号:159

请提出我们如何解决此问题的建议。.预先感谢:)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)