I would like to apply the following function to a dataframe series:
unicodedata.normalize('NFKD', c.lower().decode('utf-8')).encode('ascii','ignore')
I (sort of) understand how I can do stuff like db.cname.str.lower()
, but I'm not able to generalize to any other function after the string accessor.
How do I apply the normalize
function to all members of the series?
If c
is your string column. map
is used to apply a function elementwise (and of course you wouldn't have to chain it all together like this)
df[c] = (df[c].str.lower()
.str.decode('utf-8')
.map(lambda x: unicodedata.normalize('NFKD', x))
.str.encode('ascii', 'ignore'))
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments