Created
February 19, 2022 19:33
-
-
Save shayaf84/4365de02f5cd145d493bc9207c8c42d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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