0

I have a dataframe which contain punctuation, I want to remove it but didn't get the proper solution.

Below is the dataframe, it is a sample:

data = {'text':['Great! But we still have the punctuation and numbers.', 'my name is  %# &still  and numbers.', '&"$ value is, right']}
df = pd.DataFrame(data) 
df

I have tried the below option, but it didnt work

df['text'] = df['text'].map(lambda value:re.sub(string.punctuation,'',value)) df

Kindly suggest the best way to remove this punctuation, Note that my data-frame contain n numbers of punctuation's '!"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~'. so hard code will not be a big solutions

cronoik
  • 15,434
  • 3
  • 40
  • 78
Vish
  • 37
  • 4
  • posible duplicate of https://stackoverflow.com/questions/39782418/remove-punctuations-in-pandas – VnC May 29 '19 at 12:48
  • 1
    Possible duplicate of [Remove punctuations in pandas](https://stackoverflow.com/questions/39782418/remove-punctuations-in-pandas) – Rakesh May 29 '19 at 12:54
  • I tried the df["text1"] = df['text'].str.replace('[{}]'.format(string.punctuation), '') df["text1"] – Vish May 29 '19 at 14:21
  • I tried the the code `df["text1"] = df['text'].str.replace('[{}]'.format(string.punctuation), '') df["text1"] but it is giving error " Type aliases cannot be used with isinstance()." – Vish May 29 '19 at 14:22

0 Answers0