Created
May 10, 2020 23:01
-
-
Save jeanmidevacc/de7d1e49e349241f3244ed4a95261471 to your computer and use it in GitHub Desktop.
neo4j_count_entities_bsaber_raw
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 = """ | |
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