python3使用neo4j:py2neo v4
https://github.com/technige/py2neo
安装pip3 install py2neo
简单使用:
>>> from py2neo import *
>>> graph = Graph(password='hello')
>>> graph.run("MATCH (a:Person) RETURN a.name, a.born LIMIT 4").to_data_frame()
a.born a.name
0 NaN Ian
1 1964.0 Keanu Reeves
2 1967.0 Carrie-Anne Moss
3 1961.0 Laurence Fishburne
>>> matcher = NodeMatcher(graph)
>>> list(matcher.match("Person").where("_.name =~ 'K.*'"))
[(_21:Person {born: 1964, name: 'Keanu Reeves'}), (_39:Person {born: 1958, name: 'Kevin Bacon'}), (_40:Person {born: 1966, name: 'Kiefer Sutherland'}), (_43:Person {born: 1957, name: 'Kevin Pollak'}), (_50:Person {born: 1957, name: 'Kelly McGillis'}), (_59:Person {born: 1962, name: 'Kelly Preston'})]
>>> import pandas as pd
>>> pd.set_option('display.max_colwidth',500)
>>> graph.run('MATCH p=shortestPath((bacon:Person {name:"Kevin Bacon"})-[*]-(meg:Person {name:"Meg Ryan"}))RETURN p').to_data_frame()
p
0 ({'roles': ['Jack Swigert']}, {'roles': ['Jim Lovell']}, {'roles': ['Sam Baldwin']}, {'roles': ['Annie Reed']})