Last active
August 31, 2020 22:47
-
-
Save becahp/69b5a80994cbe33ec971956a387496b2 to your computer and use it in GitHub Desktop.
clean a string
This file contains hidden or 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
#!pip install Unidecode | |
import unidecode | |
def clean_string(str): | |
str = str.strip() | |
str = str.replace(" ","") #remover espaços | |
str = str.replace("'","") #remover apóstrofos | |
str = str.lower() #colocar tudo em minúsculas | |
str = unidecode.unidecode(str) #remover acentuação | |
return str | |
#exemplo | |
txt = "Nova Brasilândia D'Oeste oração" | |
clean_string(txt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment