Kanaries / pygwalker

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

Can't get the html from pyg.walk #630

Closed pytofu closed 1 month ago

pytofu commented 1 month ago

Hello,

I am running into a strange issue. I am testing out pygwalker in a flask app. The relevant code is here

app.py customers_df = generate_mock_data() elected_data = customers_df

Get Pygwalker as html html_str = pyg.walk(selected_data, return_html = True) return render_template('index.html', html_str=html_str)

And my index.html file has

{{ html_str }}

But when I run this locally, it always renders as follows

<pygwalker.api.pygwalker.PygWalker object at 0x14a183f20>

What could be the reason for this? I am happy to send the complete code over if you'd like

Thanks for making this awesome library

pytofu commented 1 month ago

Never mind, I figured it out.

The correct way to render html is html_str = pyg.to_html(selected_data)

And in the html file, use {{html_str | safe}}

Thanks!