Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
vgferreira
New Member

Translate a column with python using textblob library

Hi!

I'm trying to translate a column of my table, using Python's TextBlob library. this is my code.

 

from textblob import TextBlob

def translation(text):
   blob = TextBlob(text)
   return str(blob.translate(from_lang = 'pt', to = 'en'))

dataset['translation'] = dataset['CardDescription'].apply(translation)

 

 

it generates the following error.

TypeError: The `text` argument passed to `__init__(text)` must be a string, not <class 'float'>

vgferreira_1-1669231586399.png

 

however my CardDescription column is formatted as text.

vgferreira_3-1669231898588.png

 


I tested it using a string variable and it worked.

I don't know the reason for the error, can someone help me?

 

Thanks in advance!

 

1 REPLY 1
v-easonf-msft
Community Support
Community Support

Hi, @vgferreira 

This is an error message related to the python script, not powerbi.

You should check the encoding you are using for your file.

Reference:

TextBlob --- The `text` argument passed to `__init__(text)` must be a string, not <class 'float'> 

Python 2.7 and Textblob - TypeError: The `text` argument passed to `__init__(text)` must be a string... 

 

Best Regards,
Community Support Team _ Eason

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.