src/pybel/struct/summary/supersummary.py
def edge_table_df(graph: BELGraph, *, examples: bool = True, minimum: Optional[int] = None) -> pd.DataFrame:
    """Create a dataframe describing the edges in the graph."""
    edge_mapping = multidict(
        (f'{u.function} {d[RELATION]} {v.function}', graph.edge_to_bel(u, v, d, use_identifiers=True))
        for u, v, d in graph.edges(data=True)
        if d[RELATION] not in TWO_WAY_RELATIONS or u.function > v.function
    )
    edge_c = Counter({top_level_edge: len(edges) for top_level_edge, edges in edge_mapping.items()})
    if examples:
        rows = [
            (top_level_edge, count, random.choice(edge_mapping[top_level_edge]))  # noqa:S311
            for top_level_edge, count in edge_c.most_common()
            if not minimum or count >= minimum
        ]
        columns = ['Edge Type', 'Count', 'Example']
    else:
        rows = edge_c.most_common()
        if minimum:
            rows = [(k, count) for k, count in rows if count >= minimum]
        columns = ['Edge Type', 'Count']
    return pd.DataFrame(rows, columns=columns)
Create a dataframe describing the edges in the graph.
Create a dataframe describing the edges in the graph.
Create a dataframe describing the edges in the graph .
def edge_table_df(graph: BELGraph, *, examples: bool = True, minimum: Optional[int] = None) -> pd.DataFrame:
    edge_mapping = multidict(
        (f'{u.function} {d[RELATION]} {v.function}', graph.edge_to_bel(u, v, d, use_identifiers=True))
        for u, v, d in graph.edges(data=True)
        if d[RELATION] not in TWO_WAY_RELATIONS or u.function > v.function
    )
    edge_c = Counter({top_level_edge: len(edges) for top_level_edge, edges in edge_mapping.items()})
    if examples:
        rows = [
            (top_level_edge, count, random.choice(edge_mapping[top_level_edge]))  
            for top_level_edge, count in edge_c.most_common()
            if not minimum or count >= minimum
        ]
        columns = ['Edge Type', 'Count', 'Example']
    else:
        rows = edge_c.most_common()
        if minimum:
            rows = [(k, count) for k, count in rows if count >= minimum]
        columns = ['Edge Type', 'Count']
    return pd.DataFrame(rows, columns=columns)
def edge_table_df ( graph : BELGraph , * , examples : bool = True , minimum : Optional [ int ] = None ) -> pd . DataFrame : edge_mapping = multidict ( ( f'{u.function} {d[RELATION]} {v.function}' , graph . edge_to_bel ( u , v , d , use_identifiers = True ) ) for u , v , d in graph . edges ( data = True ) if d [ RELATION ] not in TWO_WAY_RELATIONS or u . function > v . function ) edge_c = Counter ( { top_level_edge : len ( edges ) for top_level_edge , edges in edge_mapping . items ( ) } ) if examples : rows = [ ( top_level_edge , count , random . choice ( edge_mapping [ top_level_edge ] ) ) for top_level_edge , count in edge_c . most_common ( ) if not minimum or count >= minimum ] columns = [ 'Edge Type' , 'Count' , 'Example' ] else : rows = edge_c . most_common ( ) if minimum : rows = [ ( k , count ) for k , count in rows if count >= minimum ] columns = [ 'Edge Type' , 'Count' ] return pd . DataFrame ( rows , columns = columns )
Create a dataframe describing the edges in the graph.
Create a dataframe describing the edges in the graph .
"""Create a dataframe describing the edges in the graph.""" # noqa:S311
graph
BELGraph
examples
bool
minimum
Optional[int]