times_excel_reader.py
def merge_tables(tables: List[EmbeddedXlTable]) -> Dict[str, DataFrame]:
    """Merge tables of the same types"""
    result = {}
    for key, value in groupby(sorted(tables, key=lambda t: t.tag), lambda t: t.tag):
        group = list(value)
        if not all(set(t.dataframe.columns) == set(group[0].dataframe.columns) for t in group):
            cols = [(",".join(g.dataframe.columns.values), g) for g in group]
            cols_groups = [(key, list(group)) for key, group in groupby(sorted(cols, key=lambda ct: ct[0]), lambda ct: ct[0])]
            print(f"WARNING: Cannot merge tables with tag {key} as their columns are not identical")
        else:
            result[key] = pd.concat([table.dataframe for table in group])
    return result
Merge tables of the same types
Merge tables of the same types
Merge tables of the same types
def merge_tables(tables: List[EmbeddedXlTable]) -> Dict[str, DataFrame]:
    result = {}
    for key, value in groupby(sorted(tables, key=lambda t: t.tag), lambda t: t.tag):
        group = list(value)
        if not all(set(t.dataframe.columns) == set(group[0].dataframe.columns) for t in group):
            cols = [(",".join(g.dataframe.columns.values), g) for g in group]
            cols_groups = [(key, list(group)) for key, group in groupby(sorted(cols, key=lambda ct: ct[0]), lambda ct: ct[0])]
            print(f"WARNING: Cannot merge tables with tag {key} as their columns are not identical")
        else:
            result[key] = pd.concat([table.dataframe for table in group])
    return result
def merge_tables ( tables : List [ EmbeddedXlTable ] ) -> Dict [ str , DataFrame ] : result = { } for key , value in groupby ( sorted ( tables , key = lambda t : t . tag ) , lambda t : t . tag ) : group = list ( value ) if not all ( set ( t . dataframe . columns ) == set ( group [ 0 ] . dataframe . columns ) for t in group ) : cols = [ ( "," . join ( g . dataframe . columns . values ) , g ) for g in group ] cols_groups = [ ( key , list ( group ) ) for key , group in groupby ( sorted ( cols , key = lambda ct : ct [ 0 ] ) , lambda ct : ct [ 0 ] ) ] print ( f"WARNING: Cannot merge tables with tag {key} as their columns are not identical" ) else : result [ key ] = pd . concat ( [ table . dataframe for table in group ] ) return result
Merge tables of the same types
Merge tables of the same types
"""Merge tables of the same types"""
tables
List[EmbeddedXlTable]