generated from AllenNeuralDynamics/aind-capsule-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from AllenNeuralDynamics/han_add_pywalker
feat: add pywalker
- Loading branch information
Showing
4 changed files
with
2,587 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pandas as pd | ||
import streamlit.components.v1 as components | ||
import streamlit as st | ||
from pygwalker.api.streamlit import init_streamlit_comm, get_streamlit_html | ||
|
||
st.set_page_config( | ||
page_title="Use Pygwalker In Streamlit", | ||
layout="wide" | ||
) | ||
|
||
st.title("Use Pygwalker In Streamlit(support communication)") | ||
|
||
# Initialize pygwalker communication | ||
init_streamlit_comm() | ||
|
||
# When using `use_kernel_calc=True`, you should cache your pygwalker html, if you don't want your memory to explode | ||
@st.cache_resource | ||
def get_pyg_html(df: pd.DataFrame) -> str: | ||
# When you need to publish your application, you need set `debug=False`,prevent other users to write your config file. | ||
html = get_streamlit_html(df, spec="./gw0.json", use_kernel_calc=False, debug=False) | ||
return html | ||
|
||
@st.cache_data | ||
def get_df() -> pd.DataFrame: | ||
return pd.read_csv("https://kanaries-app.s3.ap-northeast-1.amazonaws.com/public-datasets/bike_sharing_dc.csv") | ||
|
||
df = get_df() | ||
|
||
components.html(get_pyg_html(df), width=1300, height=1000, scrolling=True) |
Oops, something went wrong.