报错处理
报错处理record
捣蛋怪大眼萌
好好学习|积极乐观
展开
-
【error solved】‘utf-8‘ codec can‘t decode bytes in position XX-XX: invalid continuation byte
报错内容: ‘utf-8’ codec can’t decode bytes in position XX: invalid continuation byte报错原因:解析器遇到了无法解码(decode)的字符解决方法:可以尝试不同的转换器 或者 直接将无法解析的字符ignoredf = pd.read_csv('../data/filename.csv', encoding_errors = 'ignore')...转载 2022-04-29 14:25:57 · 5404 阅读 · 0 评论 -
【error solved】Error tokenizing data. C error: Expected 1 fields in line XX, saw XX
报错内容:Error tokenizing data. C error: Expected 1 fields in line XX, saw XX报错原因:CSV的分隔符设置异常 / 存储的时候格式有问题解决方法:方法一通过csv库进行读取,再遍历,再进行合并保存 (文件不大的情况下可用),太大转置的时候RAM会hangimport pandas as pdimport csv path = 'file_absolute_path/filename.csv'test = pd.DataFra转载 2022-04-27 12:10:20 · 5368 阅读 · 1 评论 -
【error solved】AttributeError: module ‘time‘ has no attribute ‘clock‘
报错源码:import time# active the time clockstart = time.clock()# here is the code need to test running time# calculate the time between start and endend = time.clock()print('运行时间 : %s 秒' %(end-start))报错内容:AttributeError module ‘time’ has no attribut转载 2022-04-27 11:41:34 · 285 阅读 · 0 评论 -
【error solved】Pandas DataFrame.to_csv raising IOError: No such file or directory
报错的意思是, 没有对应的文件夹。可能是在上一步操作的时候把路径指定了?os.chdir(path)用了网上的方法,先判断是否文件夹存在,如果不存在,就先创建对应的文件夹。import osoutname = 'filename.csv'outdir = './dir'if not os.path.exists(outdir): os.mkdir(outdir)fullname = os.path.join(outdir, outname)df.to_csv(fullname)还是原创 2022-04-27 09:46:00 · 446 阅读 · 0 评论