Update deprecated code
Browse files
app.py
CHANGED
@@ -15,8 +15,10 @@ st.set_page_config(page_title="PySQLify", page_icon="🔎", layout="wide")
|
|
15 |
st.title("PySQLify")
|
16 |
st.write("_Data Analysis_ Tool")
|
17 |
|
|
|
|
|
18 |
|
19 |
-
@st.
|
20 |
def _read_csv(f, **kwargs):
|
21 |
df = pd.read_csv(f, on_bad_lines="skip", **kwargs)
|
22 |
# clean
|
@@ -79,8 +81,8 @@ def display(df):
|
|
79 |
types_ = df.dtypes.to_dict()
|
80 |
types_ = [{"Column": c, "Type": t} for c, t in types_.items()]
|
81 |
df_ = pd.DataFrame(types_)
|
82 |
-
st.subheader("TABLE DETAILS")
|
83 |
-
st.write(df_)
|
84 |
|
85 |
|
86 |
def code_editor(language, hint, show_panel, key=None):
|
@@ -123,7 +125,7 @@ def code_editor(language, hint, show_panel, key=None):
|
|
123 |
return content
|
124 |
|
125 |
|
126 |
-
@st.
|
127 |
def query_data(sql, df):
|
128 |
try:
|
129 |
return duckdb.query(sql).df()
|
@@ -173,7 +175,7 @@ def run_python_script(user_script, key):
|
|
173 |
st.exception(e)
|
174 |
|
175 |
|
176 |
-
@st.
|
177 |
def data_profiler(df):
|
178 |
return ProfileReport(df, title="Profiling Report")
|
179 |
|
@@ -266,12 +268,12 @@ if __name__ == "__main__":
|
|
266 |
Describe the table:
|
267 |
DESCRIBE TABLE df
|
268 |
"""
|
269 |
-
number_cells = st.number_input("Number of SQL cells to use", value=1, max_value=40)
|
270 |
for i in range(number_cells):
|
271 |
col1, col2 = st.columns([2, 1])
|
272 |
st.markdown("<br>", unsafe_allow_html=True)
|
273 |
col1.write(f"> `IN[{i+1}]`")
|
274 |
-
show_panel = col2.checkbox("Show cell config panel", key=f"
|
275 |
key = f"sql{i}"
|
276 |
sql = code_editor("sql", hint, show_panel=show_panel, key=key)
|
277 |
if sql:
|
@@ -312,7 +314,7 @@ if __name__ == "__main__":
|
|
312 |
st.bar_chart(groups[i].mean())
|
313 |
```
|
314 |
"""
|
315 |
-
number_cells = st.number_input("Number of Python cells to use", value=1, max_value=40, min_value=1, help=help)
|
316 |
for i in range(number_cells):
|
317 |
st.markdown("<br><br><br>", unsafe_allow_html=True)
|
318 |
col1, col2 = st.columns([2, 1])
|
@@ -326,14 +328,14 @@ if __name__ == "__main__":
|
|
326 |
run_python_script(user_script, key=f"{user_script}{i}")
|
327 |
|
328 |
|
329 |
-
if st.checkbox("Show SQL cells", value=True):
|
330 |
sql_cells(df)
|
331 |
-
if st.checkbox("Show Python cells", value=True):
|
332 |
python_cells()
|
333 |
|
334 |
-
st.write("---")
|
335 |
|
336 |
-
if st.checkbox("Generate Data Profile Report", help="pandas profiling, generated by [ydata-profiling](https://github.com/ydataai/ydata-profiling)"):
|
337 |
st.write("---")
|
338 |
st.header("Data Profiling")
|
339 |
profile = data_profiler(df)
|
|
|
15 |
st.title("PySQLify")
|
16 |
st.write("_Data Analysis_ Tool")
|
17 |
|
18 |
+
p = st.write
|
19 |
+
print = st.write
|
20 |
|
21 |
+
@st.cache_data
|
22 |
def _read_csv(f, **kwargs):
|
23 |
df = pd.read_csv(f, on_bad_lines="skip", **kwargs)
|
24 |
# clean
|
|
|
81 |
types_ = df.dtypes.to_dict()
|
82 |
types_ = [{"Column": c, "Type": t} for c, t in types_.items()]
|
83 |
df_ = pd.DataFrame(types_)
|
84 |
+
st.sidebar.subheader("TABLE DETAILS")
|
85 |
+
st.sidebar.write(df_)
|
86 |
|
87 |
|
88 |
def code_editor(language, hint, show_panel, key=None):
|
|
|
125 |
return content
|
126 |
|
127 |
|
128 |
+
@st.cache_data
|
129 |
def query_data(sql, df):
|
130 |
try:
|
131 |
return duckdb.query(sql).df()
|
|
|
175 |
st.exception(e)
|
176 |
|
177 |
|
178 |
+
@st.cache_resource
|
179 |
def data_profiler(df):
|
180 |
return ProfileReport(df, title="Profiling Report")
|
181 |
|
|
|
268 |
Describe the table:
|
269 |
DESCRIBE TABLE df
|
270 |
"""
|
271 |
+
number_cells = st.sidebar.number_input("Number of SQL cells to use", value=1, max_value=40)
|
272 |
for i in range(number_cells):
|
273 |
col1, col2 = st.columns([2, 1])
|
274 |
st.markdown("<br>", unsafe_allow_html=True)
|
275 |
col1.write(f"> `IN[{i+1}]`")
|
276 |
+
show_panel = col2.checkbox("Show cell config panel", key=f"sql_{i}")
|
277 |
key = f"sql{i}"
|
278 |
sql = code_editor("sql", hint, show_panel=show_panel, key=key)
|
279 |
if sql:
|
|
|
314 |
st.bar_chart(groups[i].mean())
|
315 |
```
|
316 |
"""
|
317 |
+
number_cells = st.sidebar.number_input("Number of Python cells to use", value=1, max_value=40, min_value=1, help=help)
|
318 |
for i in range(number_cells):
|
319 |
st.markdown("<br><br><br>", unsafe_allow_html=True)
|
320 |
col1, col2 = st.columns([2, 1])
|
|
|
328 |
run_python_script(user_script, key=f"{user_script}{i}")
|
329 |
|
330 |
|
331 |
+
if st.sidebar.checkbox("Show SQL cells", value=True):
|
332 |
sql_cells(df)
|
333 |
+
if st.sidebar.checkbox("Show Python cells", value=True):
|
334 |
python_cells()
|
335 |
|
336 |
+
st.sidebar.write("---")
|
337 |
|
338 |
+
if st.sidebar.checkbox("Generate Data Profile Report", help="pandas profiling, generated by [ydata-profiling](https://github.com/ydataai/ydata-profiling)"):
|
339 |
st.write("---")
|
340 |
st.header("Data Profiling")
|
341 |
profile = data_profiler(df)
|