import networkx as nx
import pandas as pd
import json
entity_data = pd.DataFrame({"id":[1,1,2,3],"name":['a','aa','b','c'], "type":['x','x','y','z']})
entity_data.set_index("id", inplace=True)
#创建测试的节点数据
jsondata = '''
[
    [
        1291243,
        {
            "name": "好急的胃肠炎"
        }
    ]
]'''
print(json.loads(jsondata))
relation_data = pd.DataFrame({"src":[1,2], "dest":[2,3], "type":['normal','normal'], "weight":[1,1]})

results = entity_data[entity_data.index==5]
print(results.empty)
results = results.iloc[0]
print(results['name'])
results['name'] ='A'
print(results['name'])
results = entity_data[entity_data.index==1]
for index,data in results.iterrows():
    print(index,data['name'],data['type'])
print("----")
entity_data.loc[1, 'type'] = 'unknown'
entity_data.loc[(entity_data['name']=='b') & (entity_data.index == 2), 'type'] = 'unknown other'
for index,data in entity_data.iterrows():
    print(index,data['name'],data['type'])
print("----")
print(results)
# G = nx.from_pandas_edgelist(relation_data, "src", "dest", edge_attr=True, create_using=nx.DiGraph())
# nx.set_node_attributes(G, entity_data.set_index("id").to_dict("index"))

# print(G.nodes(data=True))
# print(G.edges(data=True))
# print(list(G.neighbors(1)))

# print(G.edges(2.0))