标签:pandas 报错 import enc sep err display expected file
数据分析和挖掘实战第15章的一段读取.txt文件报错
import pandas as pd inputfile = ‘data/meidi_jd.txt‘ outputfile = ‘data/meidi_jd_process_1.txt‘ data = pd.read_csv(inputfile,encoding = ‘utf-8‘,header =None)
File "pandas/_libs/parsers.pyx", line 965, in pandas._libs.parsers.TextReader._tokenize_rows
File "pandas/_libs/parsers.pyx", line 2208, in pandas._libs.parsers.raise_parser_error
ParserError: Error tokenizing data. C error: Expected 1 fields in line 122, saw
修改为:
import pandas as pd inputfile = ‘data/meidi_jd.txt‘ outputfile = ‘data/meidi_jd_process_1.txt‘ data = pd.read_csv(inputfile,encoding = ‘utf-8‘,header =None,sep=‘\t‘)
或者:
import pandas as pd inputfile = ‘data/meidi_jd.txt‘ outputfile = ‘data/meidi_jd_process_1.txt‘ data = pd.read_csv(inputfile,encoding = ‘utf-8‘,header =None,delimiter=‘\t‘)
ParserError: Error tokenizing data. C error: Expected 1 fields in line 122, saw 2
标签:pandas 报错 import enc sep err display expected file
原文地址:https://www.cnblogs.com/lukes1973/p/9044842.html