Reputation: 482
I found lots of post in stack overflow related to this problem. I tried those but still getting the same error. I'm using python 3.7 & wrote following code for my urdu data set
Tfidf_vect = TfidfVectorizer()
x=Tfidf_vect.fit(df['final'])
But got error message AttributeError: 'list' object has no attribute 'lower'
Then I found this stack overflow post
AttributeError: 'list' object has no attribute 'lower' : clustering. It's suggesting TfidfVectorizer only requires a list of sentences So I follow the steps mentioned in solution & modify the code & use following code
vectors = TfidfVectorizer()
dataset_list=df['final'].values.ravel().tolist()
X = vectors.fit_transform(dataset_list)
Sample data set is available here Still the same error message.Can you suggest me the steps to correc?
Upvotes: 0
Views: 208
Reputation: 404
fit_transform method accepts an iterable which yields either str, unicode or file objects as an argument. There may overlooked items in your input data. Be sure all items are str. Check via below snippet.
False in map((lambda x: type(x) == str), df['final'])
Upvotes: 1