I have a problem writing a Pandas dataframe to a csv file. I guess there are som characters that can not be translated but I do not know how to fix the problem. I need help on this.
我有一个问题,写一个熊猫dataframe到一个csv文件。我想有些som的汉字是不能翻译的,但是我不知道如何解决这个问题。我需要帮助。
Here is my simple call and the error message:
下面是我的简单调用和错误消息:
big_frame.to_csv('C:\DRO\test.csv')
error:
错误:
C:\Python27\lib\site-packages\pandas\lib.pyd in pandas.lib.write_csv_rows (pandas\lib.c:13528)()
UnicodeEncodeError: 'ascii' codec can't encode character u'\xd6' in position 1: ordinal not in range(128)
1 个解决方案
#1
14
Try using a different file encoding: big_frame.to_csv('C:\DRO\test.csv', encoding='utf-8')
尝试使用不同的文件编码:big_frame.to_csv('C:\DRO\测试)。csv”,编码= ' utf - 8”)
#1
14
Try using a different file encoding: big_frame.to_csv('C:\DRO\test.csv', encoding='utf-8')
尝试使用不同的文件编码:big_frame.to_csv('C:\DRO\测试)。csv”,编码= ' utf - 8”)