Data Formatting
General Info
Useful Snippets

9.0.20 Remove punctuation from text

Example:

def remove_punctuation(text):
    "Removes punctuation marks from a string based on Unicode puncuation characters"    
    # create a dictionary of punctuation characters using unicodedata as the keys and None as the values
    puncuation = dict.fromkeys(i for i in range(sys.maxunicode)
        if unicodedata.category(chr(i)).startswith('P'))

    # translate all characters in the text that are in the 'punctuation' dict to 'None'
    text_no_punctuation = text.translate(puncuation)
    return(text_no_punctuation)