Created
May 10, 2020 23:17
-
-
Save jeanmidevacc/7f17e790257617dd6ceef491832fabed to your computer and use it in GitHub Desktop.
neo4j_count_entities_bsaber_apoc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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