code: def apply_line_types(network):
      
  
      lines_with_types_b = network.lines.type != ""
      if lines_with_types_b.zsum() == 0:
          return
  
      missing_types = (pd.Index(network.lines.loc[lines_with_types_b, 'type'].unique())
                       .difference(network.line_types.index))
      assert missing_types.empty, ("The type(s) {} do(es) not exist in network.line_types"
                                   .format(", ".join(missing_types)))
  
      # Get a copy of the lines data
      l = (network.lines.loc[lines_with_types_b, ["type", "length", "num_parallel"]]
           .join(network.line_types, on='type'))
  
      for attr in ["r","x"]:
          l[attr] = l[attr + "_per_length"] * l["length"] / l["num_parallel"]
      l["b"] = 2*np.pi*1e-9*l["f_nom"] * l["c_per_length"] * l["length"] * l["num_parallel"]
  
      # now set calculated values on live lines
      for attr in ["r", "x", "b"]:
          network.lines.loc[lines_with_types_b, attr] = l[attr]
docs: Calculate line electrical parameters x, r, b, g from standard
      types.