-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Last set of days from 30 days challenge from streamlit with some days skipped for speed. And again some updates and changes had to be made to make code run in 2024 (the repo is from 2023 and there are some glitches with versions) 1. **e067b6b** Tasks from day 21 - Progress bar 1. **447f1a5** Task of day 22: Forms - with notation and object notation 1. **4e42ad6** Task from day 23 - Get query params from URL - https://docs.streamlit.io/develop/api-reference/caching-and-state/st.query_params - Some changes had to be performed since it is not experimental since a while 1. **ffb1885** Task from day 24 - Caching of data 1. **f2eefd2** Task of day 25 - Session state 1. **9de8075** Tasks of day 26 - Getting data from external API - With some minor changes around the parsing of API response 1. **db1d581** Task of day 27 - Draggable components 1. **65d83af** Task of day 28: Showing charts of explainability algorithm - SHAP 1. **8b99269** Task of day 30: extracting thumnbnail from YouTube videos
- Loading branch information
Showing
29 changed files
with
12,173 additions
and
0 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,15 @@ | ||
import streamlit as st | ||
import time | ||
|
||
st.title('st.progress') | ||
|
||
with st.expander('About this app'): | ||
st.write('You can now display the progress of your calculations in a Streamlit app with the `st.progress` command.') | ||
|
||
my_bar = st.progress(0) | ||
|
||
for percent_complete in range(100): | ||
time.sleep(0.05) | ||
my_bar.progress(percent_complete + 1) | ||
|
||
st.balloons() |
Large diffs are not rendered by default.
Oops, something went wrong.
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,10 @@ | ||
[tool.poetry] | ||
name = "day21" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Dickson Souza <[email protected]>"] | ||
package-mode = false | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.12" | ||
streamlit = "^1.39.0" |
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,44 @@ | ||
import streamlit as st | ||
|
||
st.title('st.form') | ||
|
||
# Full example of using the with notation | ||
st.header('1. Example of using `with` notation') | ||
st.subheader('Coffee machine') | ||
|
||
with st.form('my_form'): | ||
st.subheader('**Order your coffee**') | ||
|
||
# Input widgets | ||
coffee_bean_val = st.selectbox('Coffee bean', ['Arabica', 'Robusta']) | ||
coffee_roast_val = st.selectbox('Coffee roast', ['Light', 'Medium', 'Dark']) | ||
brewing_val = st.selectbox('Brewing method', ['Aeropress', 'Drip', 'French press', 'Moka pot', 'Siphon']) | ||
serving_type_val = st.selectbox('Serving format', ['Hot', 'Iced', 'Frappe']) | ||
milk_val = st.select_slider('Milk intensity', ['None', 'Low', 'Medium', 'High']) | ||
owncup_val = st.checkbox('Bring own cup') | ||
|
||
# Every form must have a submit button | ||
submitted = st.form_submit_button('Perform Calculation') | ||
|
||
if submitted: | ||
st.markdown(f''' | ||
☕ You have ordered: | ||
- Coffee bean: `{coffee_bean_val}` | ||
- Coffee roast: `{coffee_roast_val}` | ||
- Brewing: `{brewing_val}` | ||
- Serving type: `{serving_type_val}` | ||
- Milk: `{milk_val}` | ||
- Bring own cup: `{owncup_val}` | ||
''') | ||
else: | ||
st.write('☝️ Place your order!') | ||
|
||
|
||
# Short example of using an object notation | ||
st.header('2. Example of object notation') | ||
|
||
form = st.form('my_form_2') | ||
selected_val = form.slider('Select a value') | ||
form.form_submit_button('Submit') | ||
|
||
st.write('Selected value: ', selected_val) |
Large diffs are not rendered by default.
Oops, something went wrong.
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,10 @@ | ||
[tool.poetry] | ||
name = "day22" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Dickson Souza <[email protected]>"] | ||
package-mode = false | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.12" | ||
streamlit = "^1.39.0" |
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 streamlit as st | ||
|
||
st.title('st.experimental_get_query_params') | ||
|
||
with st.expander('About this app'): | ||
st.write("`st.experimental_get_query_params` allows the retrieval of query parameters directly from the URL of the user's browser.") | ||
|
||
# 1. Instructions | ||
st.header('1. Instructions') | ||
st.markdown(''' | ||
In the above URL bar of your internet browser, append the following: | ||
`?firstname=Jack&surname=Beanstalk` | ||
after the base URL `http://share.streamlit.io/dataprofessor/st.experimental_get_query_params/` | ||
such that it becomes | ||
`http://share.streamlit.io/dataprofessor/st.experimental_get_query_params/?firstname=Jack&surname=Beanstalk` | ||
''') | ||
|
||
# 2. Contents of st.experimental_get_query_params | ||
st.header('2. Contents of st.experimental_get_query_params') | ||
st.write(st.query_params) | ||
|
||
|
||
# 3. Retrieving and displaying information from the URL | ||
st.header('3. Retrieving and displaying information from the URL') | ||
|
||
firstname = st.query_params['firstname'] | ||
surname = st.query_params['surname'] | ||
|
||
st.write(f'Hello **{firstname} {surname}**, how are you?') |
Large diffs are not rendered by default.
Oops, something went wrong.
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,10 @@ | ||
[tool.poetry] | ||
name = "day23" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Dickson Souza <[email protected]>"] | ||
package-mode = false | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.12" | ||
streamlit = "^1.39.0" |
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,37 @@ | ||
import streamlit as st | ||
import numpy as np | ||
import pandas as pd | ||
from time import time | ||
|
||
st.title('st.cache') | ||
|
||
# Using cache | ||
a0 = time() | ||
st.subheader('Using st.cache') | ||
|
||
@st.cache_data | ||
def load_data_a(): | ||
df = pd.DataFrame( | ||
np.random.rand(2000000, 5), | ||
columns=['a', 'b', 'c', 'd', 'e'] | ||
) | ||
return df | ||
|
||
st.write(load_data_a()) | ||
a1 = time() | ||
st.info(a1-a0) | ||
|
||
# Not using cache | ||
b0 = time() | ||
st.subheader('Not using st.cache') | ||
|
||
def load_data_b(): | ||
df = pd.DataFrame( | ||
np.random.rand(2000000, 5), | ||
columns=['a', 'b', 'c', 'd', 'e'] | ||
) | ||
return df | ||
|
||
st.write(load_data_b()) | ||
b1 = time() | ||
st.info(b1-b0) |
Oops, something went wrong.