I have a .gml file like as the following:
graph [
directed 1
node [
id 0
label "5B5F2C071D12AF13219DF5EBE05132AF"
]
node [
id 1
label "9FB3B96B6D5E16C9DD564AA3E84F1954"
]
node [
id 2
label "B3299B0E587D7275E3E4D530E9EECF50"
]
node [
id 3
label "6432F1DF21BA38368D9A165C739EEBB3"
]
node [
id 4
label "85D5C50A6D882CA8E4BB00BCA3574417"
]
node [
id 5
label "0D8583F810B9720A8032BB939F12B3FF"
]
node [
id 6
label "6C10A9E9F325CAA3CCB7F9A0D6983D2A"
]
node [
id 7
label "B0C50ED1DEC9E06E4C64E7419DDC4B09"
]
]
I read this file like this:
import networkx as nx
import matplotlib.pyplot as plt
import pandas as pd
G = nx.read_gml(path)
list(G.nodes(data=True))
and I have a pandas dataframe like as below:
df = pd.DataFrame({'USER': ['5B5F2C071D12AF13219DF5EBE05132AF', '9FB3B96B6D5E16C9DD564AA3E84F1954',
'B3299B0E587D7275E3E4D530E9EECF50', '6432F1DF21BA38368D9A165C739EEBB3',
'85D5C50A6D882CA8E4BB00BCA3574417', '85D5C50A6D882CA8E4BB00BCA3574417'],
'CLASSE': [3,3,2,2,1,1]})
df
I need to merge between the two data sets so that the CLASSE attribute of the dataframe presented above is added to the network, making the network look like the following demonstration:
graph [
directed 1
node [
id 0
label "5B5F2C071D12AF13219DF5EBE05132AF"
CLASSE 3
]
...others nodes
I need to do this because I want to filter the network ober the CLASSE attribute. Can anyone help?