docs: def update_pypsa_grid_reinforcement(network, equipment_changes):
      """
      Update equipment data of lines and transformers after grid reinforcement.
  
      During grid reinforcement (cf.
      :func:`edisgo.flex_opt.reinforce_grid.reinforce_grid`) grid topology and
      equipment of lines and transformers are changed.
      In order to save time and not do a full translation of eDisGo's grid
      topology to the PyPSA format, this function provides an updater for data
      that may change during grid reinforcement.
  
      The PyPSA grid topology :meth:`edisgo.grid.network.Network.pypsa` is update
      by changed equipment stored in
      :attr:`edisgo.grid.network.Network.equipment_changes`.
  
      Parameters
      ----------
      network : Network
          eDisGo grid container
      equipment_changes : `pandas.DataFrame<dataframe>`
          Dataframe with latest equipment changes (of latest iteration step)
          from grid reinforcement. See `equipment_changes` property of
          :class:`~.grid.network.Results` for more information on the Dataframe.
  
      """
  
      # Step 1: Update transformers
      transformers = equipment_changes[
          equipment_changes['equipment'].apply(isinstance, args=(Transformer,))]
      # HV/MV transformers are excluded because it's not part of the PFA
      removed_transformers = [repr(_) for _ in
                              transformers[transformers['change'] == 'removed'][
                                  'equipment'].tolist() if _.voltage_op < 10]
      added_transformers = transformers[transformers['change'] == 'added']
  
      transformer = {'name': [],
                     'bus0': [],
                     'bus1': [],
                     'type': [],
                     'model': [],
                     'x': [],
                     'r': [],
                     's_nom': [],
                     'tap_ratio': []}
  
      for idx, row in added_transformers.iterrows():
  
          if isinstance(idx, LVStation):
              # we choose voltage of transformers' primary side
              v_base = idx.mv_grid.voltage_nom
              z_base = v_base ** 2 / row['equipment'].type.S_nom
  
              transformer['bus0'].append('_'.join(['Bus', idx.__repr__(
                  side='mv')]))
              transformer['bus1'].append('_'.join(['Bus', idx.__repr__(
                  side='lv')]))
              transformer['name'].append(repr(row['equipment']))
              transformer['type'].append("")
              transformer['model'].append('pi')
              transformer['r'].append(row['equipment'].type.R / z_base)
              transformer['x'].append(row['equipment'].type.X / z_base)
              transformer['s_nom'].append(row['equipment'].type.S_nom / 1e3)
              transformer['tap_ratio'].append(1)
  
      network.pypsa.transformers.drop(removed_transformers, inplace=True)
  
      if transformer['name']:
          network.pypsa.import_components_from_dataframe(
              pd.DataFrame(transformer).set_index('name'), 'Transformer')
  
      # Step 2: Update lines
      lines = equipment_changes.loc[equipment_changes.index[
          equipment_changes.reset_index()['index'].apply(
              isinstance, args=(Line,))]]
      changed_lines = lines[lines['change'] == 'changed']
  
      lv_stations = network.mv_grid.graph.nodes_by_attribute('lv_station')
  
      omega = 2 * pi * 50
  
      for idx, row in changed_lines.iterrows():
          # Update line parameters
          network.pypsa.lines.loc[repr(idx), 'r'] = (
              idx.type['R'] / idx.quantity * idx.length)
          network.pypsa.lines.loc[repr(idx), 'x'] = (
              idx.type['L'] / 1e3 * omega / idx.quantity * idx.length)
          network.pypsa.lines.loc[repr(idx), 's_nom'] = (
              sqrt(3) * idx.type['I_max_th'] * idx.type[
                  'U_n'] * idx.quantity / 1e3)
          network.pypsa.lines.loc[repr(idx), 'length'] = idx.length
  
          # Update buses line is connected to
          adj_nodes = idx.grid.graph.nodes_from_line(idx)
  
          if adj_nodes[0] in lv_stations:
              side = 'lv' if isinstance(idx.grid, LVGrid) else 'mv'
              bus0 = '_'.join(['Bus', adj_nodes[0].__repr__(side=side)])
          else:
              bus0 = '_'.join(['Bus', repr(adj_nodes[0])])
  
          if adj_nodes[1] in lv_stations:
              side = 'lv' if isinstance(idx.grid, LVGrid) else 'mv'
              bus1 = '_'.join(['Bus', adj_nodes[1].__repr__(side=side)])
          else:
              bus1 = '_'.join(['Bus', repr(adj_nodes[1])])
  
          network.pypsa.lines.loc[repr(idx), 'bus0'] = bus0
          network.pypsa.lines.loc[repr(idx), 'bus1'] = bus1