Forum Discussion

ganeshnr073's avatar
ganeshnr073
Icon for Helper I rankHelper I
3 years ago
Solved

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 t...
  • v-jianboli-msft's avatar
    v-jianboli-msft
    3 years ago

    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.