Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeanmidevacc/7f17e790257617dd6ceef491832fabed to your computer and use it in GitHub Desktop.
Save jeanmidevacc/7f17e790257617dd6ceef491832fabed to your computer and use it in GitHub Desktop.
neo4j_count_entities_bsaber_apoc.py
query = """
CALL db.labels() YIELD label
CALL apoc.cypher.run('MATCH (:`'+label+'`) RETURN count(*) as count',{}) YIELD value
RETURN label AS entities, value.count AS count
UNION ALL
CALL db.relationshipTypes() YIELD relationshipType as label
CALL apoc.cypher.run('MATCH ()-[:`'+label+'`]->() RETURN count(*) as count',{}) YIELD value
RETURN label AS entities, value.count AS count
"""
with driver.session() as session:
result = session.run(query)
df_count_entities_apoc = pd.DataFrame([r.values() for r in result], columns=result.keys())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment