Pandas.to_csv gives error code 'ascii' cannot encode character u '\ u2013' at position 8: ordinal not in range (128)

I am trying to save panda framework to csv and it fails with error:

df.to_csv(location, sep='|', index=False, header=True)

      

'ascii' codec cannot encode character u '\ u2013' at position 8: ordinal not in range (128)

I have a pandas version like:

>>> import pandas as pd
>>> pd.__version__
u'0.19.2'
>>>

      

The same commands work on the other machine. The pandas version is set to 0.18.1

>>> import pandas as pd
>>> pd.__version__
u'0.18.1'
>>>

      

I understand that adding encoding = 'utf-8' will lead me to error. However, I was wondering if there was a recent change that caused the unfortunate version of pandas to fail.

Thank,

+3
python pandas


source to share


No one has answered this question yet

Check out similar questions:

1207
UnicodeEncodeError: ascii codec cannot encode character u '\ xa0' at position 20: ordinal not in range (128)
314
Setting correct encoding when posting stdout in Python
86
UnicodeDecodeError: ascii codec cannot decode byte 0xef at position 1
25
UnicodeEncodeError: ascii codec cannot encode character at position 0: ordinal not in range (128)
13
Encoding gives "ascii" codec cannot encode character ... ordinal not in range (128) "
1
ascii codec cannot encode characters in position 0-3: ordinal not in range (128)
0
ascii codec cannot encode characters in position 0-4: ordinal not in range (128)
0
Python3 'ascii' cannot encode characters at position 135-136: ordinal not in range (128)
0
UTF-8 text in HDInsight cluster with 'ascii' curvature result encoding error codec cannot encode characters in position: ordinal not in range (128)
-1
ASCII codec cannot encode character u '\ u2013'



All Articles
Loading...
X
Show
Funny
Dev
Pics