In [4]:
# !pip install neo4j-driver
# !pip install pandas
# !pip install bokeh
In [1]:
from neo4j.v1 import GraphDatabase
import matplotlib.pyplot as plt
import pandas as pd
In [2]:
%matplotlib inline
plt.figure(dpi=300)
Out[2]:
In [6]:
# don't worry this is a read only user ;-)
driver = GraphDatabase.driver("bolt://165.227.223.190:7687", auth=("ppviz", "ppviz"))
In [56]:
In [7]:
with driver.session() as session:
results = session.run('''
MATCH (e:Entity)
WITH e.jurisdiction_description AS juris, COUNT(*) AS count
WHERE count > 20
RETURN *
ORDER BY count ASC
''')
In [9]:
with driver.session() as session:
results = session.run('''
match (n) return n.sourceID, labels(n), count(*) as c order by n.sourceID, c desc
''')
In [10]:
df = pd.DataFrame([dict(zip(r.keys(), r.values())) for r in results])
df
Out[10]:
In [100]:
df.plot.bar(x="labels(n)")
Out[100]:
In [ ]:
In [ ]:
In [ ]:
In [64]:
df = pd.DataFrame([dict(zip(r.keys(), r.values())) for r in results])
df
Out[64]:
In [93]:
ax = df.plot.bar(x="juris")
ax.set_xlabel("Entity Jurisdiction")
ax.set_ylabel("Number of entities")
ax.set_title("Legal Entity Count By Jurisdiction ")
plt.gcf().subplots_adjust(bottom=0.45)
plt.savefig("entity_count", dpi=300, bbox="tight")
In [16]:
from neo4j.v1 import GraphDatabase
import pandas as pd
with driver.session() as session:
results = session.run('''
MATCH (a:Address)<-[:REGISTERED_ADDRESS]-(o:Officer)--(e:Entity)
WITH a.countries AS officer_country, e.jurisdiction_description AS juris,
COUNT(*) AS num
WHERE officer_country <> juris AND num > 1000
RETURN * ORDER BY num DESC
''')
In [17]:
df = pd.DataFrame([dict(zip(r.keys(), r.values())) for r in results])
df[:5]
Out[17]:
In [37]:
from bokeh.charts import Chord
from bokeh.io import show, output_file
#df = df[df["num"] > 1000]
juris_chord = Chord(df, source="officer_country", target="juris", value="num")
output_file('juris_chord.html')
show(juris_chord)
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: