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


source to share





All Articles