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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
ganeshnr073
Helper I
Helper I

Python script error

Kindly help me with below python error :

 

DataSource.Error: ADO.NET: A problem occurred while processing your Python script.
Here are the technical details: [Expression.Error] We cannot convert the value null to type Text.
Details:
DataSourceKind=Python
DataSourcePath=Python
Message=A problem occurred while processing your Python script.
Here are the technical details: [Expression.Error] We cannot convert the value null to type Text.
ErrorCode=-2147467259
ExceptionType=Microsoft.PowerBI.Scripting.Python.Exceptions.PythonUnexpectedException

1 ACCEPTED SOLUTION

Hi @ganeshnr073 ,

 

It seems like your code is working with the SentimentIntensityAnalyzer from the nltk library to analyze the sentiment of messages in a dataset. If the code was working fine until a few days ago, it's possible that there might be some new data in the dataset causing the issue.

To handle potential null values or empty strings in the 'Message' column, you can modify the lambda function in the apply() method like this:

dataset['polairty scores'] = dataset['Message'].apply(lambda x: sia.polarity_scores(x)['compound'] if x is not None and x.strip() != '' else None)

This will check if the value is not null and not an empty string before applying the sentiment analysis. If the value is null or an empty string, it will assign None to the 'polairty scores' column for that row.

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@ganeshnr073 , share some code. the issue is with some text type variable or column

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

It working fine until few days back. I had filtered out the balnks columns as well.

 

Here is the code :

 

#load in our dependencies
import pandas as pd
from nltk.sentiment.vader import SentimentIntensityAnalyzer

#load in the sentiment analyzer
sia=SentimentIntensityAnalyzer()

#apply the analyzer over each comment
dataset['polairty scores'] =dataset['Message'].apply(lambda x: sia.polarity_scores(x)['compound'])

Hi @ganeshnr073 ,

 

It seems like your code is working with the SentimentIntensityAnalyzer from the nltk library to analyze the sentiment of messages in a dataset. If the code was working fine until a few days ago, it's possible that there might be some new data in the dataset causing the issue.

To handle potential null values or empty strings in the 'Message' column, you can modify the lambda function in the apply() method like this:

dataset['polairty scores'] = dataset['Message'].apply(lambda x: sia.polarity_scores(x)['compound'] if x is not None and x.strip() != '' else None)

This will check if the value is not null and not an empty string before applying the sentiment analysis. If the value is null or an empty string, it will assign None to the 'polairty scores' column for that row.

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for the help !!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors