How to use the split function on every row in a dataframe in Python?

前端 未结 4 1574
一向
一向 2021-02-04 05:32

I want to count the number of times a word is being repeated in the review string

I am reading the csv file and storing it in a python dataframe using the below line

4条回答
  •  余生分开走
    2021-02-04 06:17

    pandas 0.20.3 has pandas.Series.str.split() which acts on every string of the series and does the split. So you can simply split and then count the number of splits made

    len(reviews['review'].str.split('disappointed')) - 1
    

    pandas.Series.str.split

提交回复
热议问题