Skip to content

Instantly share code, notes, and snippets.

@shayaf84
Created February 19, 2022 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shayaf84/4365de02f5cd145d493bc9207c8c42d6 to your computer and use it in GitHub Desktop.
Save shayaf84/4365de02f5cd145d493bc9207c8c42d6 to your computer and use it in GitHub Desktop.
import string
#Lowercase letters
data['title'] = data['title'].str.lower()
data.head()
#Ensure that all necessary punctuations are in one list
#Include ' and " as they are not default
punc = list(string.punctuation)
punc.append('\'')
punc.append('"')
print(punc)
#Loop through dataframe and remove all punctuations
def removePunc(text):
for i in string.punctuation:
text = text.replace(i, '')
return text
# Apply to the DF series
data['title'] = data['title'].apply(removePunc)
data.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment