Pandas gives an error from str.extractall('#')
<p>I am trying to filter all the <code>#</code> keywords from the tweet text. I am using <code>str.extractall()</code> to extract all the keywords with <code>#</code> keywords. 
This  is the first time I am working on filtering keywords from the tweetText using pandas. Inputs, code, expected output and error are given below.</p>

<p>Input: </p>

<pre><code>userID,tweetText 
01, home #sweet home
01, #happy #life 
02, #world peace
03, #all are one
04, world tour
</code></pre>

<p>and so on... the total datafile is in GB size scraped tweets with several other columns. But I am interested in only two columns. </p>

<p>Code: </p>

<pre><code>import re
import pandas as pd

data = pd.read_csv('Text.csv', index_col=0, header=None, names=['userID', 'tweetText'])

fout = data['tweetText'].str.extractall('#')

print fout 
</code></pre>

<p>Expected Output: </p>

<pre><code>userID,tweetText 
01,#sweet
01,#happy 
01,#life 
02,#world
03,#all
</code></pre>

<p>Error:</p>

<pre><code>Traceback (most recent call last):
  File "keyword_split.py", line 7, in &lt;module&gt;
    fout = data['tweetText'].str.extractall('#')
  File "/usr/local/lib/python2.7/dist-packages/pandas/core/strings.py", line 1621, in extractall
    return str_extractall(self._orig, pat, flags=flags)
  File "/usr/local/lib/python2.7/dist-packages/pandas/core/strings.py", line 694, in str_extractall
    raise ValueError("pattern contains no capture groups")
ValueError: pattern contains no capture groups
</code></pre>

<p>Thanks in advance for the help. What should be the simplest way to filter keywords with respect to userid?</p>

<p>Output Update: </p>

<p>When used only this the output is like above 
<code>s.name = "tweetText"
data_1 = data[~data['tweetText'].isnull()]</code></p>

<p>The output in this case has empty <code>[]</code> and the userID at still listed and for those which has keywords has an array of keywords and not in list form. </p>

<p>When used only this the output us what needed but with <code>NAN</code></p>

<pre><code>s.name = "tweetText"
data_2 = data_1.drop('tweetText', axis=1).join(s)
</code></pre>

<p>The output here is correct format but those with no keywords has yet considered and has NAN </p>

<p>If it is possible we got to neglect such userIDs and not shown in output at all.In next stages I am trying to calculate the frequency of keywords in which the <code>NAN</code> or empty <code>[]</code> will also be counted and that frequency may compromise the far future classification. </p>

<p><a href="https://i.stack.imgur.com/VYHY4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VYHY4.png" alt="enter image description here"></a></p>