码迷,mamicode.com
首页 > 编程语言 > 详细

PYTHON::知识图谱

时间:2020-06-16 10:22:56      阅读:109      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!