Skip to content

Commit

Permalink
Tasks from day11 to 20 (#4)
Browse files Browse the repository at this point in the history
1. **26ba552** List of tags updated with inclusion of tag
`First-10-days`
1. **3b7b26b** Tasks from day 11 - Multi selector
1. **4340201** Tasks from day 12 - Check box
1. **0a690d5** Task from day 14: embed pandas profiling into streamlit
using components
   - Some changes were required to make this code to work:
- Downgrade to Python 3.9.3 due to several conflicts of
streamlit-pandas-profiling with pydantic and pandas-profiling /
ydata-profiling
- Conflict with Pydantic version 2: had to fix version in version 1 via
pydantic = "==1.*"
1. **b48fc18** Task from day 15: Latex equation
1. **e94741f** Added a .gitattributes file to normalize line endings
-
https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/
1. **2f05014** Task of day 16 - Theming
- It didn't work as easy as expected since theme conflicts with user
selection in streamlit widgets in browser's page
   - Initially config.toml was not being recognized or parsed properly
- Extra can be done via CSS hacks as next commit will show
(https://discuss.streamlit.io/t/font-size-of-slider-caption/36073/3)
1. **524d74e** CSS Hack to increase font size of slider caption
    - https://discuss.streamlit.io/t/font-size-of-slider-caption/36073/3
2. **1737c8c** Code for day 17 - Secret manipulation
1. **5bd645c** Configuration to debug streamlit applications,
interactively, in VS Code
1. **ccbe923** Conditional manipulation of secrets by streamlit. File
saved here doesn't contain any real secret. Just for learning purposes
1. **a8fe324** Example of acessing secrets in \`secrets.toml\` files
1. **ae4bf8d** Tasks from day 18: manipulating and displaying CSVs
1. **7a7450e** Task from day 19 - Layout
  • Loading branch information
disouzam authored Oct 14, 2024
2 parents 7a0f3ae + 7a7450e commit f00eed8
Show file tree
Hide file tree
Showing 31 changed files with 10,848 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gitattributes eol=lf
* text=lf
*.json eol=lf
*.py eol=lf
*.toml eol=lf
31 changes: 31 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File with Arguments",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"${command:pickArgs}"
]
},
{
"name": "Streamlit - Day17",
"type": "debugpy",
"request": "launch",
"module": "streamlit",
"args": [
"run",
"${workspaceFolder}/day17/day17.py",
"--server.port",
"8501"
],
"cwd": "${workspaceFolder}/day17"
}
]
}
10 changes: 10 additions & 0 deletions day11/day11.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import streamlit as st

st.header('st.multiselect')

options = st.multiselect(
'What are your favorite colors',
['Green', 'Yellow', 'Red', 'Blue'],
['Yellow', 'Red'])

st.write('You selected:', options)
1,173 changes: 1,173 additions & 0 deletions day11/poetry.lock

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions day11/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[tool.poetry]
name = "day11"
version = "0.1.0"
description = ""
authors = ["Dickson Souza <[email protected]>"]
license = "MIT"
readme = "README.md"
package-mode = false

[tool.poetry.dependencies]
python = "^3.12"
streamlit = "^1.39.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
18 changes: 18 additions & 0 deletions day12/day12.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import streamlit as st

st.header('st.checkbox')

st.write ('What would you like to order?')

icecream = st.checkbox('Ice cream')
coffee = st.checkbox('Coffee')
cola = st.checkbox('Cola')

if icecream:
st.write("Great! Here's some more 🍦")

if coffee:
st.write("Okay, here's some coffee ☕")

if cola:
st.write("Here you go 🥤")
1,173 changes: 1,173 additions & 0 deletions day12/poetry.lock

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions day12/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "day12"
version = "0.1.0"
description = ""
authors = ["Dickson Souza <[email protected]>"]
readme = "README.md"
package-mode = false

[tool.poetry.dependencies]
python = "^3.12"
streamlit = "^1.39.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
10 changes: 10 additions & 0 deletions day14/day14.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import streamlit as st
import pandas as pd
from streamlit_pandas_profiling import st_profile_report

st.header('`streamlit_pandas_profiling`')

df = pd.read_csv('https://raw.githubusercontent.com/dataprofessor/data/master/penguins_cleaned.csv')

pr = df.profile_report()
st_profile_report(pr)
2,335 changes: 2,335 additions & 0 deletions day14/poetry.lock

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions day14/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tool.poetry]
name = "day14"
version = "0.1.0"
description = ""
authors = ["Dickson Souza <[email protected]>"]
readme = "README.md"
package-mode = false

[tool.poetry.dependencies]
python=">=3.9,<3.9.7 || >3.9.7,<3.11"
streamlit = "^1.39.0"
streamlit-pandas-profiling = "^0.1.3"
pydantic = "==1.*"
9 changes: 9 additions & 0 deletions day15/day15.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import streamlit as st

st.header('st.latex')

st.latex(r'''
a + ar + a r^2 + a r^3 + \cdots + a r^{n-1} =
\sum_{k=0}^{n-1} ar^k =
a \left(\frac{1-r^{n}}{1-r}\right)
''')
1,173 changes: 1,173 additions & 0 deletions day15/poetry.lock

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions day15/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tool.poetry]
name = "day15"
version = "0.1.0"
description = ""
authors = ["Dickson Souza <[email protected]>"]
package-mode = false

[tool.poetry.dependencies]
python = "^3.12"
streamlit = "^1.39.0"
6 changes: 6 additions & 0 deletions day16/.streamlit/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[theme]
primaryColor="#F39C12"
backgroundColor="#85c8f5"
secondaryBackgroundColor="#ffffff"
textColor="#221d1d"
font="sans serif"
28 changes: 28 additions & 0 deletions day16/day16.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import streamlit as st

st.markdown(
"""
<style>
div[class*="stSlider"] > label > div[data-testid="stMarkdownContainer"] > p {
font-size: 30px;
}
</style>
""",
unsafe_allow_html=True
)

st.title('Customizing the theme of Streamlit apps')

st.write('Contents of the `.streamlit/config.toml` file of this app')

st.code("""
[theme]
primaryColor="#F39C12"
backgroundColor="#2E86C1"
secondaryBackgroundColor="#AED6F1"
textColor="#FFFFFF"
font="monospace"
""")

number = st.sidebar.slider('Select a number:', 0, 10, 5)
st.write('Selected number from slider widget is:', number)
1,173 changes: 1,173 additions & 0 deletions day16/poetry.lock

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions day16/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tool.poetry]
name = "day16"
version = "0.1.0"
description = ""
authors = ["Dickson Souza <[email protected]>"]
package-mode = false

[tool.poetry.dependencies]
python = "^3.12"
streamlit = "^1.39.0"
10 changes: 10 additions & 0 deletions day17/.streamlit/secrets.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Everything in this section will be available as an environment variable
db_username = "Jane"
db_password = "mypassword"

# You can also add other sections if you like.
# The contents of sections as shown below will not become environment variables,
# but they'll be easily accessible from within Streamlit anyway as we show
# later in this doc.
[my_other_secrets]
things_i_like = ["Streamlit", "Python"]
19 changes: 19 additions & 0 deletions day17/day17.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import streamlit as st

st.title('st.secrets')

try:
if 'db_username' in st.secrets:
st.write(f"db_username: {st.secrets['db_username']}")

if 'db_password' in st.secrets:
st.write(f"db_password: {st.secrets['db_password']}")

if 'my_other_secrets' in st.secrets:
st.write(f"All other secrets: {st.secrets['my_other_secrets']}")

for item in st.secrets['my_other_secrets'].items():
st.write(item)

except:
st.write("There is no secret saved.")
Loading

0 comments on commit f00eed8

Please sign in to comment.