1

I am trying to write a dataframe to excel:

writer = pd.ExcelWriter("C:/PortfolioStats.xlsx")
df.to_excel(writer, 'Data',index=False)
writer.save()

I keep getting error:

'ascii' codec can't decode byte 0xe5 in position 20: ordinal not in range(128)

It was working fine but suddenly stopped working. How do I know which data point is giving error?

Victor
  • 16,609
  • 71
  • 229
  • 409
  • why don't you use simple df.to_excel('C:/PortfolioStats.xlsx', sheet_name='Data', index=Flase)? – Sergei Aug 21 '18 at 13:39

1 Answers1

0

It's seemingly a problem with the data in the dataframe rather than anything in the code you've listed here. The answers to this previous should help you work out where the problem is beginning: UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in range(128)

smartse
  • 1,026
  • 7
  • 12