wey-gu / jupyter_nebulagraph

NebulaGraph Queries and visualization in Jupyter notebook.(previously known as ipython-ngql)
https://jupyter-nebulagraph.readthedocs.io/en/stable/
Other
28 stars 3 forks source link

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

Open maweijiao opened 1 month ago

maweijiao commented 1 month ago

%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 commented 1 month ago

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

BeautyyuYanli commented 1 month ago

@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 commented 1 month ago

Sorry I missed this issue.

The ngdraw 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 commented 1 month ago

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

hungbui-io commented 1 month ago

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

image

wey-gu commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

-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 commented 1 month ago

Dear @hungbui-io @maweijiao ,

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

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

maweijiao commented 4 weeks ago

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

wey-gu commented 4 weeks ago

@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 commented 3 weeks ago

@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