Skip to content Skip to sidebar Skip to footer

Encoding/decoding Non-ascii Character When Using Python Pandas

I have some data with non-ASCII characters. I attempted to take care of it using the following: # coding=utf-8 import pandas as pd from pandas import DataFrame, Series import sys i

Solution 1:

You could do apply combined with unidecode lib:

from unidecode import unidecode

df['name']=df['name'].apply( lambda x:  unidecode(unicode(x, encoding = "utf-8")))
df['location']=df['location'].apply( lambda x:  unidecode(unicode(x, encoding = "utf-8")))

;)

Post a Comment for "Encoding/decoding Non-ascii Character When Using Python Pandas"