Remove punctuations in pandas
<pre><code>code: df['review'].head()
        index         review
output: 0      These flannel wipes are OK, but in my opinion
</code></pre>

<p>I want to remove punctuations from the column of the dataframe and create a new column.</p>

<pre><code>code: import string 
      def remove_punctuations(text):
          return text.translate(None,string.punctuation)

      df["new_column"] = df['review'].apply(remove_punctuations)

Error:
  return text.translate(None,string.punctuation)
  AttributeError: 'float' object has no attribute 'translate'
</code></pre>

<p>I am using python 2.7. Any suggestions would be helpful.</p>

<p>Using <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.replace.html" rel="nofollow">Pandas str.replace</a> and regex:</p>

<pre><code>df["new_column"] = df['review'].str.replace('[^\w\s]','')
</code></pre>

python python-2.7 pandas