// add edges and their attributes to graph, but filter out null attribute
// values so that edges only get attributes with non-null values
for u, v, k, edge_vals in zip(gdf_edges["u"], gdf_edges["v"], gdf_edges["key"], attr_values):
edge_attrs = zip(attr_names, edge_vals)
data = {name: val for name, val in edge_attrs if isinstance(val, list) or pd.notnull(val)}
G.add_edge(u, v, key=k, **data)
After Change
// add edges and their attributes to graph, but filter out null attribute
// values so that edges only get attributes with non-null values
attr_names = gdf_edges.columns.to_list()
for (u, v, k), attr_vals in zip(gdf_edges.index, gdf_edges.values):
data_all = zip(attr_names, attr_vals)
data = {name: val for name, val in data_all if isinstance(val, list) or pd.notnull(val)}
G.add_edge(u, v, key=k, **data)