Kanaries / pygwalker

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

Can I put pygwalker into Shiny web application (shiny for python)? #118

Closed zpio closed 1 year ago

zpio commented 1 year ago

Thank you for developing an awesome program! I would like to ask about the supports for Shiny for Python (https://shiny.posit.co/py/) Please let me know if it is better to ask the Shiny's developers about it. Thanks in advances.

longxiaofei commented 1 year ago

It's a bit late to reply. (。・_・。)ノI’m sorry~

you can use pyg.walk(demo_df, return_html=True), render the returned html to any engine that can use html.

example for shiny:

from shiny import App, render, ui
import pygwalker as pyg
import pandas as pd

app_ui = ui.page_fluid(
    ui.panel_title("Pygwalker Demo"),

    ui.layout_sidebar(
      ui.panel_sidebar(),
      ui.panel_main(
        ui.output_ui("html")
      ),
    ),
)

def server(input, output, session):
    demo_df = pd.read_csv("your data file path")

    @output
    @render.ui
    def html():
        pyg_html = pyg.walk(demo_df, return_html=True)
        return ui.HTML(pyg_html)

app = App(app_ui, server)
zpio commented 1 year ago

Thank you so much.

pywalker

iainwallacebms commented 1 year ago

This is a really great example for using Shiny - I would suggest highlighting in the example documentation - https://docs.kanaries.net/pygwalker/tutorials/use-pygwalker-in-shiny