Skip to content

Instantly share code, notes, and snippets.

@Terryhung
Created November 28, 2017 02:57
Show Gist options
  • Save Terryhung/c2c4bebc93a9317f4f438da93edcf851 to your computer and use it in GitHub Desktop.
Save Terryhung/c2c4bebc93a9317f4f438da93edcf851 to your computer and use it in GitHub Desktop.
def lower_df(df):
pattern = re.compile('\W+')
for field in ['name', 'category_name', 'brand_name', 'item_description']:
_str = list(map(
lambda x: re.sub(pattern, ' ', x),
df[field].str.lower()
))
df[field] = _str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment