originally had this text df
(called train
)
index train
0 My favourite food is anything I didn't have to...
1 Now if he does off himself, everyone will thin...
2 WHY THE FUCK IS BAYLESS ISOING
3 To make her feel threatened
4 Dirty Southern Wankers
And I used this to count words in the train set:
def word_count(df):
word_count = []
for i in df['text']:
word = i.split()
word_count.append(len(word))
return word_count
train['word_count'] = word_count(train)
But I forgot applying pre processing. After applying pre processing in the texts, the df
was like this
index train
0 [favourit, food, anyth, didnt, cook]
1 [everyon, think, he, laugh, screw, peopl, inst...]
2 [fuck, bayless, iso]
3 [make, feel, threaten]
4 [dirti, southern, wanker]
And when I try to use def word_count(df):
I have an error:
AttributeError: 'list' object has no attribute 'split'
Because now I have a df
with lists inside. How can I solve this?