I tried to go through all cells from a CSV, from the column 'Text', and to make a new column named 'Type' where I'll have the type of text generated by predictions using Multinomial Naive Bayes.
This is the code:
from sklearn.naive_bayes import MultinomialNB
import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
dataset = pd.read_csv("Test.csv", encoding='latin-1')
clf = MultinomialNB()
cv = CountVectorizer()
for row in dataset:
text= row['Text']
data = cv.transform([text]).toarray()
output = clf.predict(data)
dataset['Type']=dataset[output]
This is my error:
text= row['Text']
TypeError: string indices must be integers