2 Upvotes

How to Remove Punctuation From Text with Python

Python
Data Preprocessing

import string

text = 'This +text.. has some /punctuation'
mapping = str.maketrans('', '', string.punctuation)
text = text.translate(mapping)

>> 'This text has some punctuation'

By analyseup - Last Updated March 16, 2022, 4:17 p.m.

Did you find this snippet useful?

Sign up to bookmark this in your snippet library

COMMENTS
RELATED SNIPPETS
Pivoting Pandas Dataframes
Python
Data Preprocessing

Pandas

3
2
Top Contributors
103
100