Pandas sum of all word counts in column

前端 未结 4 1096
自闭症患者
自闭症患者 2021-01-23 21:03

I have a pandas column that contains strings. I want to get a word count of all of the words in the entire column. What\'s the best way of doing that without looping through eac

4条回答
  •  醉话见心
    2021-01-23 21:29

    Numbers of words could be gotten by str count blanks+1, then sum()

    (df.a.str.count(' ')+1).sum()
    

提交回复
热议问题