PYTHON::知识图谱

2021-05-12 11:29

阅读:364

标签:where   知识图谱   das   pre   create   password   rap   creat   http   

仅当作记录

import py2neo
from py2neo import Graph,Node,Relationship
import pandas as pd

graph = Graph("http://localhost:7474")

graph = Graph("http://localhost:7474",uername="neo4j",password="lh990816")

graph.delete_all()#清空所有内容

data = pd.read_excel("D:/data.xlsx")
print(data.shape)
datalable = list(data)
data_row = len(data)
print(data_row)

# print(data.columns[1])
# b = Node(‘Person‘,name=‘yingying‘)
# graph.create(b)

datalable2 = len(datalable)
print(datalable2)
for i in range(0,data_row):
    print(data.loc[i][datalable[1]])
    Nodee = Node(impentity,name = str(data.loc[i][datalable[1]]))
    graph.create(Nodee)
    for j in range(2,datalable2):
        print(data.loc[i][j])
        print(data.columns[j])
        # if(data.loc[i][j]==data.loc[i-1][j]):
        #     selector = py2neo.matching.NodeMatcher(graph)
        #     ndoe = selector.match(‘entity‘).where(‘_.name = "data.loc[i][j]"‘).first()
        # else:
        node = Node(entity,name = str(data.loc[i][j]))
        graph.create(node)
        graph.create(Relationship(Nodee,data.columns[j],node))
#print(data.head())

 

PYTHON::知识图谱

标签:where   知识图谱   das   pre   create   password   rap   creat   http   

原文地址:https://www.cnblogs.com/a-hua/p/13139507.html


评论


亲,登录后才可以留言!