This is the code for my directed graph using the from_pandas_edgelist() command from networkx. The edge attribute is a float column of the dataframe. However when I check with print(nx.is_weighted(G)), it comes back as "False". Is there any way to add edge weights for a graph from a dataframe using from_pandas_edgelist()?
trade = pd.read_stata(df)
G_exp = nx.from_pandas_edgelist(trade, source='location_id', target='partner_id', edge_attr= 'export_value', create_using=nx.DiGraph())
nx.draw(G_exp, with_labels = True)
[G_exp][1]
[1]: https://i.stack.imgur.com/PwaXb.png