times_excel_reader.py
def expand_rows(table: EmbeddedXlTable) -> EmbeddedXlTable:
    """Expand out certain columns with entries containing commas"""

    def has_comma(s):
        return isinstance(s,str) and ',' in s

    def split_by_commas(s):
        if has_comma(s):
            return s.split(',')
        else:
            return s

    df = table.dataframe.copy()
    c = df.applymap(has_comma)
    columns_with_commas = [colname for colname in c.columns.values if c[colname].any()]
    if len(columns_with_commas) > 0:
        # Transform comma-separated strings into lists
        df = df.applymap(split_by_commas)
        for colname in columns_with_commas:
            # https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.explode.html#pandas.DataFrame.explode
            df = df.explode(colname)
    return replace(table, dataframe=df)
Expand out certain columns with entries containing commas
Expand out certain columns with entries containing commas
Expand out certain columns with entries containing commas
def expand_rows(table: EmbeddedXlTable) -> EmbeddedXlTable:
    def has_comma(s):
        return isinstance(s,str) and ',' in s
    def split_by_commas(s):
        if has_comma(s):
            return s.split(',')
        else:
            return s
    df = table.dataframe.copy()
    c = df.applymap(has_comma)
    columns_with_commas = [colname for colname in c.columns.values if c[colname].any()]
    if len(columns_with_commas) > 0:
        df = df.applymap(split_by_commas)
        for colname in columns_with_commas:
            df = df.explode(colname)
    return replace(table, dataframe=df)
def expand_rows ( table : EmbeddedXlTable ) -> EmbeddedXlTable : def has_comma ( s ) : return isinstance ( s , str ) and ',' in s def split_by_commas ( s ) : if has_comma ( s ) : return s . split ( ',' ) else : return s df = table . dataframe . copy ( ) c = df . applymap ( has_comma ) columns_with_commas = [ colname for colname in c . columns . values if c [ colname ] . any ( ) ] if len ( columns_with_commas ) > 0 : df = df . applymap ( split_by_commas ) for colname in columns_with_commas : df = df . explode ( colname ) return replace ( table , dataframe = df )
Expand out certain columns with entries containing commas
Expand out certain columns with entries containing commas
"""Expand out certain columns with entries containing commas""" # Transform comma-separated strings into lists # https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.explode.html#pandas.DataFrame.explode
table
EmbeddedXlTable