-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpainter_demo.py
51 lines (38 loc) · 1.43 KB
/
painter_demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import pandas as pd
import streamlit as st
from pygwalker.api.streamlit import init_streamlit_comm, StreamlitRenderer
from pygwalker.data_parsers.database_parser import Connector
st.set_page_config(
page_title="Streamlit Data Painter Demo",
layout="wide"
)
st.title("Streamlit Data Painter Demo")
# Initialize pygwalker communication
init_streamlit_comm()
@st.cache_resource
def get_pyg_renderer_on_df() -> "StreamlitRenderer":
df = pd.read_csv("./bestsellers with categories.csv")
# When you need to publish your application, you need set `debug=False`,prevent other users to write your config file.
return StreamlitRenderer(df, spec="ksf://bpknjjkdyyryb/demos/data_painter_demo", debug=False)
@st.cache_resource
def get_pyg_renderer_on_snowflake() -> "StreamlitRenderer":
conn = Connector(
st.secrets["SNOWFLAKE_URL"],
"""
SELECT
*
FROM
KANARIES.DEMO.AWS_BOOKS
"""
)
# When you need to publish your application, you need set `debug=False`,prevent other users to write your config file.
return StreamlitRenderer(conn, spec="ksf://bpknjjkdyyryb/demos/data_painter_demo_snowflake", debug=False)
df_renderer = get_pyg_renderer_on_df()
snowflake_renderer = get_pyg_renderer_on_snowflake()
tab1, tab2 = st.tabs(
["dataframe", "snowflake"]
)
with tab1:
df_renderer.render_explore()
with tab2:
snowflake_renderer.render_explore()