data-science-ipython-notebooks/python-core/transform_util.py

23 lines
571 B
Python
Raw Normal View History

import re
class TransformUtil:
@classmethod
def remove_punctuation(cls, value):
"""Removes !, #, and ?.
"""
return re.sub('[!#?]', '', value)
@classmethod
def clean_strings(cls, strings, ops):
"""General purpose method to clean strings.
Pass in a sequence of strings and the operations to perform.
"""
result = []
for value in strings:
for function in ops:
value = function(value)
result.append(value)
return result