I have this dataframe:
MATNR PSTAT MTART MATKL MEINS BSTME ZEINR WRKST NORMT EKWSL BRGEW
0 KDEA ZHLB 99999 EA Z005 0.089 0.089 0 FT3
1 KDVC ZPLN 99000 EA 3.14 3.14 0.015 FT3
2 KDVC ZPLN 99000 EA 3.14 3.14 0 FT3
3 KDVC ZPLN 99000 EA 3.14 3.14 0.02 FT3
and I am trying to turn it into a graph with networkX. This is the code I have thus far:
G = nx.Graph()
num_row = len(attr_df)
keys = len(attr_df.columns)
attrs = {}
for i in range(num_row):
G.add_node(attr_df['MATNR'][i], 'PSTAT'='KDEA', 'MTART' = 99999, ...)
The problem is each row has different attributes, and also if the dataset was to get more rows and columns the process of adding attributes and values would be tedious.
How can I iterate through each column to add the attributes and their value?