How to use the split function on every row in a dataframe in Python?
<p>I want to count the number of times a word is being repeated in the review string</p>

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

<pre><code>reviews = pd.read_csv("amazon_baby.csv")
</code></pre>

<p>The code in the below lines work when I apply it to a single review. </p>

<pre><code>print reviews["review"][1]
a = reviews["review"][1].split("disappointed")
print a
b = len(a)
print b
</code></pre>

<p>The output for the above lines were </p>

<pre><code>it came early and was not disappointed. i love planet wise bags and now my wipe holder. it keps my osocozy wipes moist and does not leak. highly recommend it.
['it came early and was not ', '. i love planet wise bags and now my wipe holder. it keps my osocozy wipes moist and does not leak. highly recommend it.']
2
</code></pre>

<p>When I apply the same logic to the entire dataframe using the below line. I receive an error message</p>

<pre><code>reviews['disappointed'] = len(reviews["review"].split("disappointed"))-1
</code></pre>

<p>Error message: </p>

<pre><code>Traceback (most recent call last):
  File "C:/Users/gouta/PycharmProjects/MLCourse1/Classifier.py", line 12, in &lt;module&gt;
    reviews['disappointed'] = len(reviews["review"].split("disappointed"))-1
  File "C:\Users\gouta\Anaconda2\lib\site-packages\pandas\core\generic.py", line 2360, in __getattr__
    (type(self).__name__, name))
AttributeError: 'Series' object has no attribute 'split'
</code></pre>