I am gettin an attribute error when using graphdatascience to construct a graph from a simple dataframe. I am unsure what is missing from my code to make it work
import pandas as pd
import neo4j
from graphdatascience import GraphDataScience
gds = GraphDataScience("bolt://localhost:7687", auth=None)
nodes = pandas.DataFrame(
{
"nodeId": [0, 1, 2, 3],
"labels": ["A", "B", "C", "A"],
"prop1": [42, 1337, 8, 0],
"otherProperty": [0.1, 0.2, 0.3, 0.4]
}
)
relationships = pandas.DataFrame(
{
"sourceNodeId": [0, 1, 2, 3],
"targetNodeId": [1, 2, 3, 0],
"relationshipType": ["REL", "REL", "REL", "REL"],
"weight": [0.0, 0.0, 0.1, 42.0]
}
)
G = gds.alpha.graph.construct(
"my-graph", # Graph name
nodes, # One or more dataframes containing node data
relationships # One or more dataframes containing relationship data
)
UnableToConnectError: Couldn't connect to localhost:7687 (resolved to ('[::1]:7687', '127.0.0.1:7687')):
Failed to establish connection to ResolvedIPv6Address(('::1', 7687, 0, 0)) (reason [Errno 61] Connection refused)
Failed to establish connection to ResolvedIPv4Address(('127.0.0.1', 7687)) (reason [Errno 61] Connection refused)
Beware of copying code because there is a note that says "Use your neo4j credentials according to your setup"
https://neo4j.com/docs/graph-data-science/current/python-client/getting-started/#_import_and_setup
from graphdatascience import GraphDataScience
**# Use Neo4j URI and credentials according to your setup**
gds = GraphDataScience("bolt://localhost:7687", auth=("neo4j", "my-awesome-psw"))
print(gds.version())
Result:
2.1.4
The error you are getting is because it is unable to connection to your local database without authentication (auth=None)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.