Skip to content

Using a function to alter text in a string column #8791

Answered by ozgurkalan
ozgurkalan asked this question in Q&A
Discussion options

You must be logged in to vote

this works well:

    @classmethod
    def col_serializer(cls, t:Table, col:str, *args:int)->Table:
        """squeezes the string column into trimmed args and serializes the given column
        
        t: ibis table, which is the latest modified one or a pandas df
        col: str, column name to be squeezed
        args: int, max length of the string, can be comma separated, if not given 5, 15 used
        
        """
        # pattern to clean the string
        pattern = r'[!"#$%&\'()*+,-./:;<=>?@\[\\\]^_`{|}~\s]'
        
        def trans(col):
            col = col.re_replace(pattern,'')
            for a,b in tuple(zip("ğĞıİöÖüÜşŞçÇ", "gGiIoOuUsScC")):
                col = col.r…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@ozgurkalan
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by cpcloud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants