yeffon
yeffon

Reputation: 9

TypeError: object of type 'float' has no len() for Sentimental Analysis

Trying some Sentimental Analysis on some csv files and keep getting an error I'm not sure how to fix

I tried changing in the loop type.

readFeedback = pandas.read_csv("Feedback.csv", header=0, escapechar="\\", 
                    index_col="nps_score", error_bad_lines=False)

cleanedAnswers = []

for i in range(0, len(readFeedback["question_22"])) :
    cleanedAnswers.append(" ".join( KaggleWord2VecUtility.review_to_wordlist(readFeedback["question_22"][i], True)))

I expended it to clean the questions of stop words but it gave me the error:

TypeError: object of type 'float' has no len() for Sentimental Analysis

Upvotes: 0

Views: 147

Answers (1)

Salman Farsi
Salman Farsi

Reputation: 466

for i in range(0, len(readFeedback["question_22"])) :

Here you have len(readFeedback["question_22"]):, This isn't any list that can be iterated through. It's a float.

Change it to an iterable and it'll work right.

Upvotes: 1

Related Questions