Pandas遇到的安装和使用问题

时间:2024-05-18 15:44:02

Q:

在centos,python2.7安装pandas的时候,一直提醒未找到version>=1.9.0的numpy,其实已经安装了1.14.0的numpy。报错如下:

 

Pandas遇到的安装和使用问题

 

A:

 

用命令:pip uninstall numpy;pip install --upgrade setuptools;pip install --user numpy scipy matplotlib jupyter pandas ;卸载了原来的numpy;更新了一下setuptools依赖;再重新安装就好了。其实最后一条命令安装太多了,可以根据需要视情况删掉某几个。最后安装好的numpy版本是1.11.0。

Q:

描述:用pandas的read_csv读取csv格式的文件时,根本不能读。

 

报错:

Traceback (most recent call last):

  File "E:/iiii/ML/transfor.py", line 100, in <module>
    news=pd.read_csv("passall-.csv")
  File "D:\Python27\lib\site-packages\pandas\io\parsers.py", line 709, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "D:\Python27\lib\site-packages\pandas\io\parsers.py", line 455, in _read
    data = parser.read(nrows)
  File "D:\Python27\lib\site-packages\pandas\io\parsers.py", line 1069, in read
    ret = self._engine.read(nrows)
  File "D:\Python27\lib\site-packages\pandas\io\parsers.py", line 1839, in read
    data = self._reader.read(nrows)
  File "pandas\_libs\parsers.pyx", line 902, in pandas._libs.parsers.TextReader.read
  File "pandas\_libs\parsers.pyx", line 924, in pandas._libs.parsers.TextReader._read_low_memory
  File "pandas\_libs\parsers.pyx", line 978, in pandas._libs.parsers.TextReader._read_rows
  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
pandas.errors.ParserError: Error tokenizing data. C error: Expected 10 fields in line 6, saw 11

A:

出现这种报错的情况有很多,我遇到的情况的解决方式是将文件的编码格式改为UTF8BOM格式即可。不要用UltraEdit...