相关疑难解决方法(0)

使用Python在Pandas中读取CSV文件时的UnicodeDecodeError

我正在运行一个处理30,000个类似文件的程序.随机数量正在停止并产生此错误......

   File "C:\Importer\src\dfman\importer.py", line 26, in import_chr
     data = pd.read_csv(filepath, names=fields)
   File "C:\Python33\lib\site-packages\pandas\io\parsers.py", line 400, in parser_f
     return _read(filepath_or_buffer, kwds)
   File "C:\Python33\lib\site-packages\pandas\io\parsers.py", line 205, in _read
     return parser.read()
   File "C:\Python33\lib\site-packages\pandas\io\parsers.py", line 608, in read
     ret = self._engine.read(nrows)
   File "C:\Python33\lib\site-packages\pandas\io\parsers.py", line 1028, in read
     data = self._reader.read(nrows)
   File "parser.pyx", line 706, in pandas.parser.TextReader.read (pandas\parser.c:6745)
   File "parser.pyx", line 728, in pandas.parser.TextReader._read_low_memory (pandas\parser.c:6964)
   File "parser.pyx", line 804, in pandas.parser.TextReader._read_rows (pandas\parser.c:7780)
   File "parser.pyx", line 890, in pandas.parser.TextReader._convert_column_data (pandas\parser.c:8793)
   File "parser.pyx", line 950, in pandas.parser.TextReader._convert_tokens …
Run Code Online (Sandbox Code Playgroud)

python csv unicode dataframe pandas

329
推荐指数
13
解决办法
32万
查看次数

pandas.read_csv中dtype和转换器之间有什么区别?

pandas函数read_csv()读取.csv文件.它的文档在这里

根据文件,我们知道:

dtype:列的类型名称或字典 - > type,default无数据或列的数据类型.例如{'a':np.float64,'b':np.int32}(不支持engine ='python')

converter:dict,default无用于转换某些列中的值的函数的字典.键可以是整数或列标签

使用此功能时,我可以调用 pandas.read_csv('file',dtype=object)pandas.read_csv('file',converters=object).显然,转换器,它的名字可以说数据类型将被转换,但我想知道dtype的情况?

python types type-inference converter pandas

16
推荐指数
2
解决办法
2万
查看次数

标签 统计

pandas ×2

python ×2

converter ×1

csv ×1

dataframe ×1

type-inference ×1

types ×1

unicode ×1