Skip to content

Instantly share code, notes, and snippets.

@MLWhiz
Created January 18, 2019 05:46
Show Gist options
  • Select an option

  • Save MLWhiz/cfc73813ee9663a7a52b5d749c7bb83d to your computer and use it in GitHub Desktop.

Select an option

Save MLWhiz/cfc73813ee9663a7a52b5d749c7bb83d to your computer and use it in GitHub Desktop.
def clean_numbers(x):
if bool(re.search(r'\d', x)):
x = re.sub('[0-9]{5,}', '#####', x)
x = re.sub('[0-9]{4}', '####', x)
x = re.sub('[0-9]{3}', '###', x)
x = re.sub('[0-9]{2}', '##', x)
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment