When I try to use:
df[df.columns.difference(['pos', 'neu', 'neg', 'new_description'])].to_csv('sentiment_data.csv')
I get the error:
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud83d' in position 388: surrogates not allowed
I don't understand what this error means and how I can fix this error and export my data to a csv/excel. I have referred to this question but I don't understand much and it doesn't answer how to do this with pandas.
What does position 388 mean? What is the character '\ud83d'?
I get a different error position when I try to export to an excel:
df[df.columns.difference(['pos', 'neu', 'neg', 'new_description'])].to_excel('sentiment_data_new.xlsx')
Error while exporting to excel:
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud83d' in position 261: surrogates not allowed
Why is the position different when it's the same encoding?
The other duplicate questions don't answer how to escape this error with pandas DataFrame.