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/de7d1e49e349241f3244ed4a95261471 to your computer and use it in GitHub Desktop.
Save jeanmidevacc/de7d1e49e349241f3244ed4a95261471 to your computer and use it in GitHub Desktop.
neo4j_count_entities_bsaber_raw
query = """
MATCH (n:User)
WITH count(n) as count
RETURN 'User' as entities, count
UNION ALL
MATCH (n:Song)
WITH count(n) as count
RETURN 'Song' as entities, count
UNION ALL
MATCH (n1:User)-[r:BUILT]->(n2:Song)
WITH count(r) as count
RETURN 'BUILT' as entities, count
UNION ALL
MATCH (n1:User)-[r:REVIEWED]->(n2:Song)
WITH count(r) as count
RETURN 'REVIEWED' as entities, count
UNION ALL
MATCH (n1:User)-[r:BOOKMARKED]->(n2:Song)
WITH count(r) as count
RETURN 'BOOKMARKED' as entities, count
UNION ALL
MATCH (n1:User)-[r:FOLLOWS]->(n2:User)
WITH count(r) as count
RETURN 'FOLLOWS' as entities, count
UNION ALL
MATCH (n1:User)-[r:IS_FOLLOWED_BY]->(n2:User)
WITH count(r) as count
RETURN 'IS_FOLLOWED_BY' as entities, count
UNION ALL
MATCH (n1:User)-[r:IS_FRIEND_WITH]->(n2:User)
WITH count(r) as count
RETURN 'IS_FRIEND_WITH' as entities, count
"""
with driver.session() as session:
result = session.run(query)
df_count_entities = 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