使用pandas读取csv文件时出错

时间:2017-04-10 18:42:49

标签: python python-3.x csv pandas

我是Python上的新用户,我对如何通过" pd.read_csv"正确读取csv文件存有这种基本疑问。来自pandas包。

我的代码如下:

import pandas as pd

import numpy as np

test = pd.read_csv('C:/Users/marcu/Desktop/teste.csv')

它给出了这条错误信息:

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    test = pd.read_csv('C:/Users/marcu/Desktop/teste.csv')
  File "C:\Users\marcu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 646, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "C:\Users\marcu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 389, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "C:\Users\marcu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 730, in __init__
    self._make_engine(self.engine)
  File "C:\Users\marcu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 923, in _make_engine
    self._engine = CParserWrapper(self.f, **self.options)
  File "C:\Users\marcu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 1390, in __init__
    self._reader = _parser.TextReader(src, **kwds)
  File "pandas\parser.pyx", line 535, in pandas.parser.TextReader.__cinit__ (pandas\parser.c:6086)
  File "pandas\parser.pyx", line 740, in pandas.parser.TextReader._get_header (pandas\parser.c:9266)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe7 in position 22: invalid continuation byte

我该如何解决这个问题?!

感谢您的关注, 马库斯。

0 个答案:

没有答案