I am trying to tokenize a sentence in a pandas dataframe but I am having some trouble
I know this code works to covert just one row
TextBlob(df['H'][0]).words
But when I tried to apply it in a for loop I got an error
for i, row in df.H():
ifor_val = TextBlob(df['H'][i]).words
df.at[i,'ifor'] = H
Error message: TypeError: 'Series' object is not callable
Edit:
data = {'H':['the quick brown fox jumps over the road', 'the weather is nice
today'], 'marks':[99, 98]}
df = pd.DataFrame(data)
desired
H marks
['the','quick','brown', 'fox'....] 99
['the','weather','is', 'nice'....] 98
SOLUTION:
df['H']=df['H'].apply(word_tokenize) df['H'].head()