cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Query problem in Graph Algorithm Book

Hi all. I'm new with this neo4j and graph algorithm. So I try to use the book Graph Algorithm by Needham and Hodler to do some practical exercise. But when i run
query = """
MATCH (article:Article)
RETURN article.year AS year, count(*) AS count
ORDER BY year
"""
by_year = graph.run(query).to_data_frame()

in the neo4j browser, i got this error

Invalid input 'q': expected (line 1, column 1 (offset: 0))
"query = """"
Can anyone help to solve this?
Thanks

8 REPLIES 8

llpree
Graph Buddy

First off, welcome to the community. I'll need more info as I think we're mixing tools. If you could pass the page number in the great book or just tell me what you want to do, that'll help me help you. Running the CYPHER bit works fine. The other code is not CYPHER but does look like it could belong in something like Python or R which might be trying to run the CYPHER within that context, returning a data frame for processing. So to start with, that will not work in the Browser which got confused as it parses the letter "q". Looking forward to your clarifications and again, "welcome"!

Thanks llpree for your reply. Really appreciate it. For that i already solved it. I need to run in python.
But when i try to run graph.run(query).to_data_frame() in python, then i face the error. I get this error:
'NoneType' object has no attribute 'split'. (book's page no -194 & 198)
And when i passed the query about train.missing.link(pg 198) my neo4j browser become black screen.

The Python error indicates that the query did not get any data and hence has None as datatype. Trying to do a split for a string on a None datatype results in the error.

Sadly I don't have the book so its rather difficult to see the cause without seeing the code.

Thanks for your reply. Really appreciate it
Here is the screen shot of the book. Page 193 and 194.

2X_b_b799bf215aab698f4a372832892cf1e068a3f405.jpeg

Thanks for sharing, did you create the Article and Author data in the database?
I am assuming this is done earlier in the book, but if that somehow fails it would explain that the Python code does not pick up any data.

ya.. im using exactly the same dataset .Here the print screen for page 192

webtic
Graph Fellow

Found a free copy of the book, bit short on time at the moment but I will try to work through the example in the weekend. To be continued.

Thank you so much...