Hi
I have been using Pyxll and the Neo4j python driver to input and retrieve data from the DB.
I am trying to extract the correct elements of the query result in Python and it seems that getting the syntax correct to create the result in a dataframe and show all the results of the query is a little challenging.
The documentation does not contain an example of what the query statement and arguments would look like in the code.
Does anyone have an example?
Cheers
This is a really broad question. Without knowing what data there is in your DB (or rather its structure) and knowing what you want to query/insert/update, there's is no answer to your question.
I recommend you have a look at the Cypher manual (Cypher being the query language used with Neo4j) Introduction - Cypher Manual
Hi
thanks for answering but it is actually the documentation that raises the question.
In the docs, it says
pandas_df = driver.execute_query(
- UNWIND range(1, 10) AS n RETURN n, n+1 AS m",
*** database_="neo4j",*
- result_transformer_=neo4j.Result.to_df*
)
print(type(pandas_df)) # <class 'pandas.core.frame.DataFrame'>
This transformer accepts two optional arguments:
expand — If True, some data structures in the result will be recursively expanded and flattened. More info in the API documentation.
parse_dates — If True, columns exclusively containing time.DateTime objects, time.Date objects, or None, will be converted to pandas.Timestamp.
If you need to pass parameters to to_df, use lambda functions:
result_transformer_=lambda res: res.to_df(True)
What I would appreciate the help with is if others have succeeded in using the expand element successfully and what the statement looks like.
Currently, I am just using some code to break up the results but I think working in the dataframe would make more sense - if I can get it to work.
Cheers
Andy