0

Imagine I have the following dataframe

         text                 category
0     "The cat runs..."          1
1     "Why is that..."           2
2     "The job is very..."       2
3     "For some reason..."       2
4     "The level of..."          1        

I would like to make two separate plots that for each category, 1 and 2, that shows the length of the number of words for each observations found in that category

So far, I have tried to split the data frame for each category (category1 and category2) and apply the following for, let's say category 1:

 x = category1['text'].apply(lambda x: len(x.split()))

My plan was to make a barplot for this x

But for some reason I get the error that: 'Series' object is not callable

Anyone that has a different or better approach?

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
teller.py3
  • 822
  • 8
  • 22

0 Answers0