0

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?

Sonia
  • 464
  • 10
  • 21
  • Please provide a sample of your input data – G. Anderson May 07 '20 at 21:42
  • Please [edit] your question to include samples of your input data in your question, not as a link or picture, to make a [mcve]. It's highly relevant to know exactly what _your_ data (`df`) looks like right before you call the transformer on it. See [How to make good pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – G. Anderson May 07 '20 at 23:19

1 Answers1

1

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'])
erncnerky
  • 394
  • 3
  • 10