UnicodeEncodeError:'ascii'在pandas python 2.7中导出csv

时间:2015-07-30 09:46:20

标签: python-2.7 csv pandas unicode

我在python 2.7中创建了一个pandas DataFrame

当我尝试使用函数

将其导出为csv时
outcome.to_csv("/Users/john/out_1.csv")

我收到以下错误:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 191: ordinal not in range(128)

如何出口呢?如果我不能怎么去191位并移除那个角色?

非常感谢

编辑:

数据框如下所示:

0         CA0037381      LSAL:G97715947CF      CA0037381LSAL:G97715947CF   
1         CA0037381      LSAL:G97717947CF      CA0037381LSAL:G97717947CF   
2         CA0037684          HINT:13426CF          CA0037684HINT:13426CF   
3         CA0037679     WAVE:JLA0901BRNCF     CA0037679WAVE:JLA0901BRNCF   
4         CA0037373  HUGR:5026134836266CF  CA0037373HUGR:5026134836266CF   
5         CA0037601       WAST:WGCH23BLCF       CA0037601WAST:WGCH23BLCF   
6         CA0037601        WAST:WG19800CF        CA0037601WAST:WG19800CF   
7         CA0037318         ENDO:ALBARINO         CA0037318ENDO:ALBARINO   
8         CA0037319        HEAV:XYG001ACF        CA0037319HEAV:XYG001ACF   
9         CA0037319     TWOS:4782-20TWOCF     CA0037319TWOS:4782-20TWOCF   
10        CA0037320          SERE:BD635/A          CA0037320SERE:BD635/A   
11        CA0037321          CASG:12285CF          CA0037321CASG:12285CF   

注意:这只是一小部分,因为它是16330行x 372列。数据集非常稀疏(即许多空白单元格)

0 个答案:

没有答案