docs: def calc_line_losses(network):
      """ Calculate losses per line with PF result data
      
      Parameters
      ----------
      network : :class:`pypsa.Network
          Overall container of PyPSA
      s0 : series
          apparent power of line
      i0 : series
          current of line
      -------
  
      """
  
      # Line losses
      # calculate apparent power S = sqrt(p² + q²) [in MW]
      s0_lines = ((network.lines_t.p0**2 + network.lines_t.q0**2).
                  apply(np.sqrt))
      # calculate current I = S / U [in A]
      i0_lines = np.multiply(s0_lines, 1000000) / \
          np.multiply(network.lines.v_nom, 1000)
      # calculate losses per line and timestep network.\
      # lines_t.line_losses = I² * R [in MW]
      network.lines_t.losses = np.divide(i0_lines**2 * network.lines.r, 1000000)
      # calculate total losses per line [in MW]
      network.lines = network.lines.assign(
          losses=np.sum(network.lines_t.losses).values)
  
      # Transformer losses
      # https://books.google.de/books?id=0glcCgAAQBAJ&pg=PA151&lpg=PA151&dq=
      # wirkungsgrad+transformator+1000+mva&source=bl&ots=a6TKhNfwrJ&sig=
      # r2HCpHczRRqdgzX_JDdlJo4hj-k&hl=de&sa=X&ved=
      # 0ahUKEwib5JTFs6fWAhVJY1AKHa1cAeAQ6AEIXjAI#v=onepage&q=
      # wirkungsgrad%20transformator%201000%20mva&f=false
      # Crastan, Elektrische Energieversorgung, p.151
      # trafo 1000 MVA: 99.8 %
      network.transformers = network.transformers.assign(
          losses=np.multiply(network.transformers.s_nom, (1 - 0.998)).values)
  
      # calculate total losses (possibly enhance with adding these values
      # to network container)
      losses_total = sum(network.lines.losses) + sum(network.transformers.losses)
      print("Total lines losses for all snapshots [MW]:", round(losses_total, 2))
      losses_costs = losses_total * np.average(network.buses_t.marginal_price)
      print("Total costs for these losses [EUR]:", round(losses_costs, 2))
  
      return