Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%ng_draw AssertionError: Result is not in Pandas DataFrame Style #57

Open
maweijiao opened this issue May 22, 2024 · 12 comments · Fixed by #66
Open

%ng_draw AssertionError: Result is not in Pandas DataFrame Style #57

maweijiao opened this issue May 22, 2024 · 12 comments · Fixed by #66
Assignees
Labels
bug Something isn't working

Comments

@maweijiao
Copy link

%config IPythonNGQL.ngql_result_style="pandas"

%ngql MATCH (p:entity)-[e:relationship]->(m:entity) WHERE p.entity.name == '迈克尔·鲁克' RETURN p,e,m
%ng_draw


AssertionError Traceback (most recent call last)
Input In [14], in <cell line: 1>()
----> 1 get_ipython().run_line_magic('ng_draw', '')

File D:\P\anaconda3\lib\site-packages\IPython\core\interactiveshell.py:2294, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
2292 kwargs['local_ns'] = self.get_local_scope(stack_depth)
2293 with self.builtin_trap:
-> 2294 result = fn(*args, **kwargs)
2295 return result

File D:\P\anaconda3\lib\site-packages\ngql\magic.py:378, in IPythonNGQL.ng_draw(self, line, cell, local_ns)
376 return "No result found, please execute a query first."
377 result_df = local_ns[variable_name]
--> 378 assert isinstance(
379 result_df, pd.DataFrame
380 ), "Result is not in Pandas DataFrame Style"
382 # Create a graph
383 g = Network(
384 notebook=True,
385 directed=True,
(...)
391 neighborhood_highlight=True,
392 )

AssertionError: Result is not in Pandas DataFrame Style

image

不太清楚问题出在了哪里,谢谢~

@hungbui-io
Copy link

@maweijiao Hi, I am facing the same issue. Pls let me know if you have any update on this. Thanks

@BeautyyuYanli
Copy link
Collaborator

@maweijiao @hungbui-io I guess the two lines is enough:

%ngql MATCH (p:entity)-[e:relationship]->(m:entity) WHERE p.entity.name == '迈克尔·鲁克' RETURN p,e,m
%ng_draw

No need to config anything

@wey-gu
Copy link
Owner

wey-gu commented May 30, 2024

Sorry I missed this issue.

The ng_draw command can be done only after the query being done, a 'df=_' call will interrupt the context needed for ng_draw.

Could you do ng_draw follow the ngql one by one? This should work.

The df = _ could be evaluated with another ngql call.

We can add feature to draw from a df later to improve this later.

@wey-gu
Copy link
Owner

wey-gu commented May 30, 2024

Also, now ng_draw will be working with both result formats in latest release.

@hungbui-io
Copy link

Hi @wey-gu . I am still facing the issue...Any idea?

image

@wey-gu
Copy link
Owner

wey-gu commented May 30, 2024

Hi @wey-gu . I am still facing the issue...Any idea?

image

Dear @hungbui-io

Would you mind helping perform pip install -U this package to see how it goes with latest version?

As from your backtrack, it's shown with an older version and in the current release, I make it try to cast other styles of output into pd df.

@maweijiao
Copy link
Author

The original version of my installation package was 0.12.4. After I upgraded this installation package, it still reported an error if I did not set “IPythonNGQL.ngql_result_style=“pandas””. After setting it, it can be displayed normally.
微信图片_20240603090154
微信截图_20240603090211

After setting it, it can be displayed normally.
微信图片_20240603090952

@hungbui-io
Copy link

-U

Hi @wey-gu, thanks for your support. I have updated the package to 0.13.1, and here is the new error.
[ERROR]: the last execution result is not a %ngql query, make a query first or use %ng_draw <some query> instead, please. Something wrong with the result parsing: { "Nodes": [ "Access key", "Anonymized completely", "Access key value", "Auto-populates in anonymized format - *****", "In anonymized format", "Actian avalanche", "Inputs according to actian's connection support", "Data warehouse", "Action", "View details and delete", "Delete button", "Edit button", "Action column", "Right side", "Publish icon", "Re-run button", "Actions column", "Edit", "Add", "Adding filled details", "Add button", "Particular rule detail and display it in a table below", ... "Heading": "" } Error: 'Network' object has no attribute 'keys'

@wey-gu
Copy link
Owner

wey-gu commented Jun 5, 2024

Dear @hungbui-io @maweijiao ,

The latest release I just made 0.13.2 should fix the above issues:

  • Now it renders raw style result set in last cell
  • Now it renders when ng_draw was run twice in a row

Kindly help verify your use case when possible, thanks!!

@wey-gu wey-gu self-assigned this Jun 5, 2024
@wey-gu wey-gu added the bug Something isn't working label Jun 6, 2024
@maweijiao
Copy link
Author

maweijiao commented Jun 7, 2024

@wey-gu Thanks!When I upgraded, there was an error, regardless of whether I set ‘IPythonNGQL.ngql_result_style=“pandas”’.
微信截图_20240607181211
微信图片_20240607181826

@wey-gu
Copy link
Owner

wey-gu commented Jun 7, 2024

@maweijiao thanks a lot for the test! Could you please help share what queries are you using to trigger such error? And/or any queries will end up such error? As I cannot reproduce it in my env.

@wey-gu
Copy link
Owner

wey-gu commented Jun 12, 2024

@maweijiao I had tried different types of queries and render with %ng_draw, all run perfectly.

%ngql GET SUBGRAPH 2 STEPS WITH PROP FROM "p_0" YIELD VERTICES AS nodes, EDGES AS relationships;
%%ngql
MATCH path_0=(n)--() WHERE id(n) == "p_0"
OPTIONAL MATCH path_1=(n)--()--()
RETURN path_0, path_1
%%ngql
MATCH (n)-[e]-(m) WHERE id(n) == "p_0"
OPTIONAL MATCH (n)-[e1]-(a)-[e2]-(b)
RETURN n,m,e,e1,e2,a,b
%ngql FIND ALL PATH WITH PROP FROM "p_5703" TO "p_5742" OVER * BIDIRECT YIELD path AS p;
Screenshot 2024-06-12 at 18 06 35 Screenshot 2024-06-12 at 18 07 01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants