Kanaries / pygwalker

PyGWalker: Turn your pandas dataframe into an interactive UI for visual analysis
https://kanaries.net/pygwalker
Apache License 2.0
12.86k stars 665 forks source link

Support for Pygwalker Data Visualizations in `marimo` #638

Open Haleshot opened 5 days ago

Haleshot commented 5 days ago

Is your feature request related to a problem? Please describe. When attempting to use pygwalker within marimo (a Python notebook framework), I encountered an issue where marimo was unable to display the pygwalker visualization. Specifically, I received the error message:

Unsupported mimetype: application/vnd.jupyter.widget-view+json

image This prevents users from utilizing pygwalker's data visualization capabilities within marimo notebooks.

Describe the solution you'd like I would like pygwalker to implement support for marimo by adding either a __repr_html__ or __mime__ method to the pygwalker.api.pygwalker.PygWalker class. This would allow marimo to properly render pygwalker visualizations, as described in the marimo documentation for displaying objects.

Describe alternatives you've considered I initially tried using pygwalker with marimo following the standard instructions provided in the pygwalker repository, similar to how it's used in Jupyter notebooks. However, this approach resulted in the aforementioned error.

Additional context This feature request originated from an attempt to integrate pygwalker with marimo, as documented in marimo issue #2486. I got suggested filing this feature request with pygwalker to implement the necessary methods for compatibility.

Implementing this feature would greatly enhance the usability of pygwalker across different Python notebook environments, particularly benefiting users of marimo who wish to use pygwalker's data visualization capabilities.

mscolnick commented 5 days ago

Specifically, returning the pgwalker instance at the end of the cell just calls __repr__, when no _repr_html_ is provided. It would be great to add a _repr_html_ so that it can be rendered properly in other environments that follow this spec.

image