def lv_to_pypsa(network):
    """
    Convert LV grid topology to PyPSA representation

    Includes grid topology of all LV grids of :attr:`~.grid.grid.Grid.lv_grids`

    Parameters
    ----------
    network : Network
        eDisGo grid container

    Returns
    -------
    dict of :pandas:`pandas.DataFrame<dataframe>`
        A DataFrame for each type of PyPSA components constituting the grid
        topology. Keys included

        * 'Generator'
        * 'Load'
        * 'Line'
        * 'BranchTee'
        * 'StorageUnit'
    """

    generators = []
    loads = []
    branch_tees = []
    lines = []
    lv_stations = []
    storages = []

    for lv_grid in network.mv_grid.lv_grids:
        generators.extend(lv_grid.graph.nodes_by_attribute('generator'))
        loads.extend(lv_grid.graph.nodes_by_attribute('load'))
        branch_tees.extend(lv_grid.graph.nodes_by_attribute('branch_tee'))
        lines.extend(lv_grid.graph.lines())
        lv_stations.extend(lv_grid.graph.nodes_by_attribute('lv_station'))
        storages.extend(lv_grid.graph.nodes_by_attribute('storage'))

    omega = 2 * pi * 50

    generator = {'name': [],
                 'bus': [],
                 'control': [],
                 'p_nom': [],
                 'type': [],
                 'p_nom_extendable': [],
                 'p_nom_min': [],
                 'p_nom_max': [],
                 'capital_cost': []
                 }

    bus = {'name': [], 'v_nom': [], 'x': [], 'y': []}

    load = {'name': [], 'bus': []}

    line = {'name': [],
            'bus0': [],
            'bus1': [],
            'type': [],
            'x': [],
            'r': [],
            's_nom': [],
            's_nom_min': [],
            's_max_pu': [],
            's_nom_extendable': [],
            'capital_cost': [],
            'length': []}

    storage = {
        'name': [],
        'bus': [],
        'p_nom': [],
        'p_nom_extendable': [],
        'p_nom_min': [],
        'p_nom_max': [],
        'capital_cost': [],
        'max_hours': []}

    # create dictionary representing generators and associated buses
    for gen in generators:
        bus_name = '_'.join(['Bus', repr(gen)])
        generator['name'].append(repr(gen))
        generator['bus'].append(bus_name)
        generator['control'].append('PQ')
        generator['p_nom'].append(gen.nominal_capacity / 1e3)
        generator['type'].append('_'.join([gen.type, gen.subtype]))
        generator['p_nom_extendable'].append(False)
        generator['p_nom_min'].append(0)  # 0.3
        generator['p_nom_max'].append(0)
        generator['capital_cost'].append(0)

        bus['name'].append(bus_name)
        bus['v_nom'].append(gen.grid.voltage_nom)
        bus['x'].append(None)
        bus['y'].append(None)

    # create dictionary representing branch tees
    for bt in branch_tees:
        bus['name'].append('_'.join(['Bus', repr(bt)]))
        bus['v_nom'].append(bt.grid.voltage_nom)
        bus['x'].append(None)
        bus['y'].append(None)

    # create dataframes representing loads and associated buses
    for lo in loads:
        bus_name = '_'.join(['Bus', repr(lo)])
        load['name'].append(repr(lo))
        load['bus'].append(bus_name)

        bus['name'].append(bus_name)
        bus['v_nom'].append(lo.grid.voltage_nom)
        bus['x'].append(None)
        bus['y'].append(None)

    # create dataframe for lines
    for l in lines:
        line['name'].append(repr(l['line']))

        if l['adj_nodes'][0] in lv_stations:
            line['bus0'].append(
                '_'.join(['Bus', l['adj_nodes'][0].__repr__(side='lv')]))
        else:
            line['bus0'].append('_'.join(['Bus', repr(l['adj_nodes'][0])]))

        if l['adj_nodes'][1] in lv_stations:
            line['bus1'].append(
                '_'.join(['Bus', l['adj_nodes'][1].__repr__(side='lv')]))
        else:
            line['bus1'].append('_'.join(['Bus', repr(l['adj_nodes'][1])]))

        line['type'].append("")
        line['x'].append(
            l['line'].type['L'] * omega / 1e3 * l['line'].length)
        line['r'].append(l['line'].type['R'] * l['line'].length)
        s_nom = sqrt(3) * l['line'].type['I_max_th'] * \
                l['line'].type['U_n'] / 1e3
        line['s_nom'].append(s_nom)
        line['s_nom_min'].append(s_nom)
        line['s_max_pu'].append(0.6)
        line['s_nom_extendable'].append(True)
        line['capital_cost'].append(100)
        line['length'].append(l['line'].length)

    lv_components = {
        'Generator': pd.DataFrame(generator).set_index('name'),
        'Bus': pd.DataFrame(bus).set_index('name'),
        'Load': pd.DataFrame(load).set_index('name'),
        'Line': pd.DataFrame(line).set_index('name'),
        'StorageUnit': pd.DataFrame(storage).set_index('name')}

    return lv_components