0

Does anyone know another option to solve the UnicodeEncodeError in a dataframe ?

UnicodeEncodeError: 'charmap' codec can't encode character '\u0394' in position 15: character maps to <undefined>

I've identified that the row where set the error contain this symbol

(ΔT)

this problem arises after importing the excel file and in a column that apparently is empty I get the error, that using python 3.9

I have tried to solve by applying the code below but the error remains the same.

df['DB_user'].str.encode('ascii', 'ignore').str.decode('ascii')

Thanks !

Mirna
  • 21
  • 5
  • Have you tried [this solution](https://stackoverflow.com/a/9942822/13891969)? – luca Feb 10 '23 at 10:29
  • I have tried but it keeps giving the same error – Mirna Feb 10 '23 at 11:12
  • 1
    Please paste the error text in the question as a code instead of using an image of it, is there a way we can access the excel file you are testing? and the code the makes this error for you. – Lidor Eliyahu Shelef Feb 10 '23 at 13:03
  • If your file contains unicode (which it does), you cannot fit that into ASCII. – erip Feb 10 '23 at 13:50
  • 1
    thank you all ! I have solved the error with the following code `df['DB_user']=str(df['DB_user']).encode('ascii', 'ignore')` – Mirna Feb 10 '23 at 14:28
  • 1
    We're happy to hear this, please now answer your question so that future programmers that will come here will be able to see it clearly :) – Lidor Eliyahu Shelef Feb 10 '23 at 14:30

0 Answers0