Problem: You've a feature of text data and want to remove punctuaiton
Soluation: Define a function that uses translate with a dictionary of punctuation characters:
# Load libraries
import unicodedata
import sys
# Create text
text_data = ['Hi!!!! I. Love. This. Song....',
'10000% Agree!!!! #LoveIT',
'Right?!?!']
# Create a dictionary of punctuation characters
punctuation = dict.fromkeys(i for i in range(sys.maxunicode)
if unicodedata.category(chr(i)).startswith('P'))
# For each string, remove any punctuation characters
[string.translate(punctuation) for string in text_data]
result: ['Hi I Love This Song', '10000 Agree LoveIT', 'Right']
from "Chris_Albon]_Machine_Learning_with_Python_Cookbook"