I have data frame and there are 2 columns with unicode value. I need to convert it to string. I try df.domain.astype(str) but it return unicode strings.
How can I do that?
Data looks like (I need to convert either columns)
domain search_term
vk.com None
facebook.com None
yandex.ru снять квартиру
locals.ru None
yandex.ru снять квартиру без посредников в Москве
avito.ru None
Would this help?:
for col in types[types=='unicode'].index:
df[col] = df[col].astype(str)
or:
for col in types[types=='unicode'].index:
df[col] = df[col].apply(lambda x: x.encode('utf-8').strip())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With