Skip to content

Instantly share code, notes, and snippets.

View petehughes's full-sized avatar

Pete Hughes petehughes

View GitHub Profile
%%cypher -o table
load csv with headers from "https://raw.githubusercontent.com/nicola/tubemaps/master/datasets/london.stations.csv" as csv
return csv limit 5
%load_ext cypher-magic
%cypher -r
%cypher -p <passsword> -s neo4j+s://<server>
# assume that
# pip install matplotlib seaborn
p= %cypher match (t:Transfer) where t.numericFee is not null and t.numericFee > 0 return t.numericFee as numericFee, t.season as season
# create anew year value based on the start year of the season
p['year'] = p['season'].str[:4]
p['numericFee'] = p['numericFee'].divide(1000000)
gb = p.groupby("season").sum()
gb.plot.bar()
gb
%%cypher
MATCH path = shortestPath( (:Station {name:'Watford'})-[:LEG*]-(:Station {name: 'Liverpool Street'}) )
with [n in nodes(path)|n.name] as Stations, [n in relationships(path)|n.line] as AlLines, reduce(time = 0, n in relationships(path) | time + n.time) as time
where time > 0
with [i in range(0, size(AlLines)-1)
WHERE i=0 OR AlLines[i] <> AlLines[i-1] | AlLines[i] ] AS Lines, AlLines, Stations, time
RETURN Lines, Stations, time
@petehughes
petehughes / connect to neo4j server.py
Created July 12, 2022 18:36
connect to neo4j server
# reset connection
%cypher -r
# this will show:
# Neo4j database connection reset...
# connect to myserver using the username of neo4j and the password of password
%cypher -s myserver -u neo4j -p password
# this will show:
# Neo4j database connection established... bolt://myserver:7687
pip install --upgrade git+https://github.com/innovationOUtside/cypher_magic.git
@petehughes
petehughes / pip install.py
Last active July 12, 2022 18:31
install cypher-magic
pip install cypher-magic