1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > python pandas读取数据报错:Traceback (most recent call last):anaconda3/lib/python3.7/site-packages/pandas/i

python pandas读取数据报错:Traceback (most recent call last):anaconda3/lib/python3.7/site-packages/pandas/i

时间:2022-12-23 13:16:38

相关推荐

python pandas读取数据报错:Traceback (most recent call last):anaconda3/lib/python3.7/site-packages/pandas/i

具体报错信息:

Traceback (most recent call last):File "<stdin>", line 1, in <module>File "/home/dengfei/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py", line 676, in parser_freturn _read(filepath_or_buffer, kwds)File "/home/dengfei/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py", line 448, in _readparser = TextFileReader(fp_or_buf, **kwds)File "/home/dengfei/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py", line 880, in __init__self._make_engine(self.engine)File "/home/dengfei/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py", line 1114, in _make_engineself._engine = CParserWrapper(self.f, **self.options)File "/home/dengfei/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py", line 1868, in __init__ParserBase.__init__(self, kwds)File "/home/dengfei/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py", line 1416, in __init__"Passing negative integer to header is invalid. "ValueError: Passing negative integer to header is invalid. For no header, use header=None instead

报错命令:

pd.read_csv("a.txt",header=-1,sep="\s+")

报错原因:

pandas升级了,不支持"header=-1"这种写法了,改为了:“header=None”

解决方法:

pd.read_csv("a.txt",header=None,sep="\s+")

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。