How to remove square brackets in result pos_tag
<p>I want to extract nouns from dataframe. I do as below</p>

<pre><code>import pandas as pd
import nltk
from nltk.tag import pos_tag
df = pd.DataFrame({'pos': ['noun', 'Alice', 'good', 'well', 'city']})
noun=[]
for index, row in df.iterrows():
    noun.append([word for word,pos in pos_tag(row) if pos == 'NN'])
df['noun'] = noun  
</code></pre>

<p>and i get df['noun']</p>

<pre><code>0     [noun]
1    [Alice]
2         []
3         []
4     [city]
</code></pre>

<p>I use regex </p>

<pre><code>df['noun'].replace('[^a-zA-Z0-9]', '', regex = True)
</code></pre>

<p>and again</p>

<pre><code>0     [noun]
1    [Alice]
2         []
3         []
4     [city]
Name: noun, dtype: object
</code></pre>

<p>what's wrong?</p>

<p>The bracket means you have lists in each cell of the data frame. If you are sure there is only one element at most in each list, you can use <code>str</code> on the noun column and extract the first element:</p>

<pre><code>df['noun'] = df.noun.str[0]

df
#    pos    noun
#0  noun    noun
#1  Alice   Alice
#2  good    NaN
#3  well    NaN
#4  city    city
</code></pre>

python nltk pos-tagger