我目前正在尝试构建一个相当简单的脚本,它将比较来自 CSV 的两个 DataFrame 并执行内部合并以删除重复项。现在我注意到我的一个 CSV 文件如下所示:
Row [0]: One column
Row [1:]: 2+ columns
现在,当我尝试通过 pandas.csv_read(...) 导入它时,我收到以下错误
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/pandas-0.10.0-py2.7-macosx-10.5-i386.egg/pandas/io/parsers.py", line 391, in parser_f
return _read(filepath_or_buffer, kwds)
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/pandas-0.10.0-py2.7-macosx-10.5-i386.egg/pandas/io/parsers.py", line 207, in _read
return parser.read()
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/pandas-0.10.0-py2.7-macosx-10.5-i386.egg/pandas/io/parsers.py", line 624, in read
ret = self._engine.read(nrows)
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/pandas-0.10.0-py2.7-macosx-10.5-i386.egg/pandas/io/parsers.py", line 945, in read
data = self._reader.read(nrows)
File "parser.pyx", line 634, in pandas._parser.TextReader.read (pandas/src/parser.c:5795)
File "parser.pyx", line 656, in pandas._parser.TextReader._read_low_memory (pandas/src/parser.c:6015)
File "parser.pyx", line 734, in pandas._parser.TextReader._read_rows (pandas/src/parser.c:6892)
File "parser.pyx", line 791, in pandas._parser.TextReader._convert_column_data (pandas/src/parser.c:7596)
File "parser.pyx", line 1015, in pandas._parser.TextReader._get_column_name (pandas/src/parser.c:10425)
我认为这与第一行有关,因为当我删除它时,问题就消失了。我怎样才能忽略这些错误并用空值填充其余部分?
最好的,奥利弗