0

I have a dataframe where I have symbols such as %22 and I am trying to replace them using urllib. For other files this code worked perfectly but for some reason I am getting this error. Any ideas how I can fix this. As far as I know I am using utf-8.

df = pd.read_csv('Data\Genres\cleanedGenreArtistSong.csv',engine = 'python', encoding = 'utf-8-sig')
df['Song'] = df['Song'].apply(lambda x:urllib.unquote(x).decode('utf8') )

The error I am getting is:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 1: ordinal not in range(128)

This is a snapshot of my dataframe:

enter image description here

Saveen
  • 3,742
  • 14
  • 32
  • 38
joe borg
  • 93
  • 1
  • 5

0 Answers0