mirror of
https://github.com/donnemartin/data-science-ipython-notebooks.git
synced 2024-03-22 13:30:56 +08:00
23 lines
571 B
Python
23 lines
571 B
Python
|
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
|