■ selectbox 함수를 사용해 선택 박스를 만드는 방법을 보여준다. ▶ main.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
import pandas as pd import streamlit as st dataFrame = pd.DataFrame( { "first column" : [ 1, 2, 3, 4], "second column" : [10, 20, 30, 40] } ) option = st.selectbox( "Which number do you like best?", dataFrame["first column"] ) "You selected : ", option |
▶ requirements.txt
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
|
altair==5.3.0 attrs==23.2.0 blinker==1.8.2 cachetools==5.3.3 certifi==2024.6.2 charset-normalizer==3.3.2 click==8.1.7 gitdb==4.0.11 GitPython==3.1.43 idna==3.7 Jinja2==3.1.4 jsonschema==4.22.0 jsonschema-specifications==2023.12.1 markdown-it-py==3.0.0 MarkupSafe==2.1.5 mdurl==0.1.2 numpy==2.0.0 packaging==24.1 pandas==2.2.2 pillow==10.3.0 protobuf==5.27.1 pyarrow==16.1.0 pydeck==0.9.1 Pygments==2.18.0 python-dateutil==2.9.0.post0 pytz==2024.1 referencing==0.35.1 requests==2.32.3 rich==13.7.1 rpds-py==0.18.1 six==1.16.0 smmap==5.0.1 streamlit==1.36.0 tenacity==8.4.1 toml==0.10.2 toolz==0.12.1 tornado==6.4.1 typing_extensions==4.12.2 tzdata==2024.1 urllib3==2.2.2 watchdog==4.0.1 |
※ pip install streamlit 명령을 실행했다.
■ checkbox 함수에서 체크 박스를 사용해 데이터 표시 여부를 설정하는 방법을 보여준다. ▶ main.py
|
import streamlit as st import pandas as pd import numpy as np if st.checkbox("데이터 프레임 표시"): dataFrame = pd.DataFrame( np.random.randn(20, 3), columns = ["a", "b", "c"] ) dataFrame |
▶ requirements.txt
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
|
altair==5.3.0 attrs==23.2.0 blinker==1.8.2 cachetools==5.3.3 certifi==2024.6.2 charset-normalizer==3.3.2 click==8.1.7 gitdb==4.0.11 GitPython==3.1.43 idna==3.7 Jinja2==3.1.4 jsonschema==4.22.0 jsonschema-specifications==2023.12.1 markdown-it-py==3.0.0 MarkupSafe==2.1.5 mdurl==0.1.2 numpy==2.0.0 packaging==24.1 pandas==2.2.2 pillow==10.3.0 protobuf==5.27.1 pyarrow==16.1.0 pydeck==0.9.1 Pygments==2.18.0 python-dateutil==2.9.0.post0 pytz==2024.1 referencing==0.35.1 requests==2.32.3 rich==13.7.1 rpds-py==0.18.1 six==1.16.0 smmap==5.0.1 streamlit==1.36.0 tenacity==8.4.1 toml==0.10.2 toolz==0.12.1 tornado==6.4.1 typing_extensions==4.12.2 tzdata==2024.1 urllib3==2.2.2 watchdog==4.0.1 |
※ pip install streamlit
더 읽기
■ text_input 함수를 사용해 텍스트 입력을 만드는 방법을 보여준다. ▶ main.py
|
import streamlit as st st.text_input("성명", key = "name") # 다음을 사용하여 언제든지 값에 액세스할 수 있다 : st.session_state.name |
▶ requirements.txt
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
|
altair==5.3.0 attrs==23.2.0 blinker==1.8.2 cachetools==5.3.3 certifi==2024.6.2 charset-normalizer==3.3.2 click==8.1.7 gitdb==4.0.11 GitPython==3.1.43 idna==3.7 Jinja2==3.1.4 jsonschema==4.22.0 jsonschema-specifications==2023.12.1 markdown-it-py==3.0.0 MarkupSafe==2.1.5 mdurl==0.1.2 numpy==2.0.0 packaging==24.1 pandas==2.2.2 pillow==10.3.0 protobuf==5.27.1 pyarrow==16.1.0 pydeck==0.9.1 Pygments==2.18.0 python-dateutil==2.9.0.post0 pytz==2024.1 referencing==0.35.1 requests==2.32.3 rich==13.7.1 rpds-py==0.18.1 six==1.16.0 smmap==5.0.1 streamlit==1.36.0 tenacity==8.4.1 toml==0.10.2 toolz==0.12.1 tornado==6.4.1 typing_extensions==4.12.2 tzdata==2024.1 urllib3==2.2.2 watchdog==4.0.1 |
※ pip install streamlit 명령을 실행했다.
■ slider 함수를 사용해 슬라이더를 만드는 방법을 보여준다. ▶ main.py
|
import streamlit as st x = st.slider("x") st.write(x, "squared is", x * x) |
▶ requirements.txt
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
|
altair==5.3.0 attrs==23.2.0 blinker==1.8.2 cachetools==5.3.3 certifi==2024.6.2 charset-normalizer==3.3.2 click==8.1.7 gitdb==4.0.11 GitPython==3.1.43 idna==3.7 Jinja2==3.1.4 jsonschema==4.22.0 jsonschema-specifications==2023.12.1 markdown-it-py==3.0.0 MarkupSafe==2.1.5 mdurl==0.1.2 numpy==2.0.0 packaging==24.1 pandas==2.2.2 pillow==10.3.0 protobuf==5.27.1 pyarrow==16.1.0 pydeck==0.9.1 Pygments==2.18.0 python-dateutil==2.9.0.post0 pytz==2024.1 referencing==0.35.1 requests==2.32.3 rich==13.7.1 rpds-py==0.18.1 six==1.16.0 smmap==5.0.1 streamlit==1.36.0 tenacity==8.4.1 toml==0.10.2 toolz==0.12.1 tornado==6.4.1 typing_extensions==4.12.2 tzdata==2024.1 urllib3==2.2.2 watchdog==4.0.1 |
※ pip install streamlit 명령을 실행했다.
■ map 함수에서 DataFrame 객체를 사용해 지도를 만드는 방법을 보여준다. ▶ main.py
|
import pandas as pd import numpy as np import streamlit as st dataFrame = pd.DataFrame( np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4], columns = ["lat", "lon"]) st.map(dataFrame) |
▶ requirements.txt
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
|
altair==5.3.0 attrs==23.2.0 blinker==1.8.2 cachetools==5.3.3 certifi==2024.6.2 charset-normalizer==3.3.2 click==8.1.7 gitdb==4.0.11 GitPython==3.1.43 idna==3.7 Jinja2==3.1.4 jsonschema==4.22.0 jsonschema-specifications==2023.12.1 markdown-it-py==3.0.0 MarkupSafe==2.1.5 mdurl==0.1.2 numpy==2.0.0 packaging==24.1 pandas==2.2.2 pillow==10.3.0 protobuf==5.27.1 pyarrow==16.1.0 pydeck==0.9.1 Pygments==2.18.0 python-dateutil==2.9.0.post0 pytz==2024.1 referencing==0.35.1 requests==2.32.3 rich==13.7.1 rpds-py==0.18.1 six==1.16.0 smmap==5.0.1 streamlit==1.36.0 tenacity==8.4.1 toml==0.10.2 toolz==0.12.1 tornado==6.4.1 typing_extensions==4.12.2 tzdata==2024.1 urllib3==2.2.2 watchdog==4.0.1 |
※ pip install streamlit 명령을 실행했다.
■ line_chart 함수에서 DataFrame 객체를 사용해 라인 차트를 만드는 방법을 보여준다. ▶ main.py
|
import pandas as pd import numpy as np import streamlit as st dataFrame = pd.DataFrame( np.random.randn(20, 3), columns = ["a", "b", "c"] ) st.line_chart(dataFrame) |
▶ requirements.txt
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
|
altair==5.3.0 attrs==23.2.0 blinker==1.8.2 cachetools==5.3.3 certifi==2024.6.2 charset-normalizer==3.3.2 click==8.1.7 gitdb==4.0.11 GitPython==3.1.43 idna==3.7 Jinja2==3.1.4 jsonschema==4.22.0 jsonschema-specifications==2023.12.1 markdown-it-py==3.0.0 MarkupSafe==2.1.5 mdurl==0.1.2 numpy==2.0.0 packaging==24.1 pandas==2.2.2 pillow==10.3.0 protobuf==5.27.1 pyarrow==16.1.0 pydeck==0.9.1 Pygments==2.18.0 python-dateutil==2.9.0.post0 pytz==2024.1 referencing==0.35.1 requests==2.32.3 rich==13.7.1 rpds-py==0.18.1 six==1.16.0 smmap==5.0.1 streamlit==1.36.0 tenacity==8.4.1 toml==0.10.2 toolz==0.12.1 tornado==6.4.1 typing_extensions==4.12.2 tzdata==2024.1 urllib3==2.2.2 watchdog==4.0.1 |
※ pip install streamlit 명령을
더 읽기
■ dataframe 함수의 생성자에서 PANDAS의 Styler 객체를 사용해 대화형 테이블의 일부 요소를 강조 표시하는 방법을 보여준다. ▶ main.py
|
import pandas as pd import numpy as np import streamlit as st dataFrame = pd.DataFrame( np.random.randn(10, 20), columns = ("col %d" % i + 1 for i in range(20)) ) st.dataframe(dataFrame.style.highlight_max(axis = 0)) |
▶ requirements.txt
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
|
altair==5.3.0 attrs==23.2.0 blinker==1.8.2 cachetools==5.3.3 certifi==2024.6.2 charset-normalizer==3.3.2 click==8.1.7 gitdb==4.0.11 GitPython==3.1.43 idna==3.7 Jinja2==3.1.4 jsonschema==4.22.0 jsonschema-specifications==2023.12.1 markdown-it-py==3.0.0 MarkupSafe==2.1.5 mdurl==0.1.2 numpy==2.0.0 packaging==24.1 pandas==2.2.2 pillow==10.3.0 protobuf==5.27.1 pyarrow==16.1.0 pydeck==0.9.1 Pygments==2.18.0 python-dateutil==2.9.0.post0 pytz==2024.1 referencing==0.35.1 requests==2.32.3 rich==13.7.1 rpds-py==0.18.1 six==1.16.0 smmap==5.0.1 streamlit==1.36.0 tenacity==8.4.1 toml==0.10.2 toolz==0.12.1 tornado==6.4.1 typing_extensions==4.12.2 tzdata==2024.1 urllib3==2.2.2 watchdog==4.0.1 |
더 읽기
■ table 함수에서 DataFrame 객체를 사용해 정적 테이블을 만드는 방법을 보여준다. ▶ main.py
|
import pandas as pd import streamlit as st dataFrame = pd.DataFrame( { "first column" : [ 1, 2, 3, 4], "second column" : [10, 20, 30, 40] } ) st.table(dataFrame) |
▶ requirements.txt
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
|
altair==5.3.0 attrs==23.2.0 blinker==1.8.2 cachetools==5.3.3 certifi==2024.6.2 charset-normalizer==3.3.2 click==8.1.7 gitdb==4.0.11 GitPython==3.1.43 idna==3.7 Jinja2==3.1.4 jsonschema==4.22.0 jsonschema-specifications==2023.12.1 markdown-it-py==3.0.0 MarkupSafe==2.1.5 mdurl==0.1.2 numpy==2.0.0 packaging==24.1 pandas==2.2.2 pillow==10.3.0 protobuf==5.27.1 pyarrow==16.1.0 pydeck==0.9.1 Pygments==2.18.0 python-dateutil==2.9.0.post0 pytz==2024.1 referencing==0.35.1 requests==2.32.3 rich==13.7.1 rpds-py==0.18.1 six==1.16.0 smmap==5.0.1 streamlit==1.36.0 tenacity==8.4.1 toml==0.10.2 toolz==0.12.1 tornado==6.4.1 typing_extensions==4.12.2 tzdata==2024.1 urllib3==2.2.2 watchdog==4.0.1 |
※ pip install streamlit 명령을
더 읽기
■ dataframe 함수에서 ndarray 객체를 사용해 대화형 테이블을 만드는 방법을 보여준다. ▶ main.py
|
import numpy as np import streamlit as st ndArray = np.random.randn(10, 20) # 행, 열 st.dataframe(ndArray) |
▶ requirements.txt
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
|
altair==5.3.0 attrs==23.2.0 blinker==1.8.2 cachetools==5.3.3 certifi==2024.6.2 charset-normalizer==3.3.2 click==8.1.7 gitdb==4.0.11 GitPython==3.1.43 idna==3.7 Jinja2==3.1.4 jsonschema==4.22.0 jsonschema-specifications==2023.12.1 markdown-it-py==3.0.0 MarkupSafe==2.1.5 mdurl==0.1.2 numpy==2.0.0 packaging==24.1 pandas==2.2.2 pillow==10.3.0 protobuf==5.27.1 pyarrow==16.1.0 pydeck==0.9.1 Pygments==2.18.0 python-dateutil==2.9.0.post0 pytz==2024.1 referencing==0.35.1 requests==2.32.3 rich==13.7.1 rpds-py==0.18.1 six==1.16.0 smmap==5.0.1 streamlit==1.36.0 tenacity==8.4.1 toml==0.10.2 toolz==0.12.1 tornado==6.4.1 typing_extensions==4.12.2 tzdata==2024.1 urllib3==2.2.2 watchdog==4.0.1 |
※ pip install streamlit 명령을
더 읽기
■ dataframe 함수에서 DataFrame 객체를 사용해 대화형 테이블을 만드는 방법을 보여준다. ▶ main.py
|
import pandas as pd import streamlit as st dataFrame = pd.DataFrame( { "first column" : [ 1, 2, 3, 4], "second column" : [10, 20, 30, 40] } ) st.dataframe(dataFrame) |
▶ requirements.txt
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
|
altair==5.3.0 attrs==23.2.0 blinker==1.8.2 cachetools==5.3.3 certifi==2024.6.2 charset-normalizer==3.3.2 click==8.1.7 gitdb==4.0.11 GitPython==3.1.43 idna==3.7 Jinja2==3.1.4 jsonschema==4.22.0 jsonschema-specifications==2023.12.1 markdown-it-py==3.0.0 MarkupSafe==2.1.5 mdurl==0.1.2 numpy==2.0.0 packaging==24.1 pandas==2.2.2 pillow==10.3.0 protobuf==5.27.1 pyarrow==16.1.0 pydeck==0.9.1 Pygments==2.18.0 python-dateutil==2.9.0.post0 pytz==2024.1 referencing==0.35.1 requests==2.32.3 rich==13.7.1 rpds-py==0.18.1 six==1.16.0 smmap==5.0.1 streamlit==1.36.0 tenacity==8.4.1 toml==0.10.2 toolz==0.12.1 tornado==6.4.1 typing_extensions==4.12.2 tzdata==2024.1 urllib3==2.2.2 watchdog==4.0.1 |
※ pip install streamlit 명령을
더 읽기
■ HELLO WORLD 앱을 만드는 방법을 보여준다. (UBUNTU) 1. CTRL + ALT + T 키를 눌러서 [터미널]을 실행한다. 2. [터미널]에서 아래 명령을
더 읽기