일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- del
- Machine Learning
- nan
- sklearn
- 반복문
- count()
- list
- analizer
- IN
- Python
- function
- wcss
- elbow method
- data
- 덴드로그램
- matplotlib
- 최댓값
- DataAccess
- len()
- dendrogram
- insert()
- hierarchical_clustering
- DataFrame
- Dictionary
- string
- pandas
- 분류 결과표
- numpy
- 최솟값
- append()
- Today
- Total
목록Python/Streamlit (19)
개발공부

아래와 같이 간단한 app.py를 만들어보자. import streamlit as st def main() : st.sidebar.selectbox('메뉴', '1') st.title('안녕하세요') st.button('버튼') if __name__ == '__main__' : main() 그 후 app.py 을 run 해보자 streamlit run app.py 실행된 웹에서 오른쪽 상단 메뉴모양을 클릭하고 Settings로 들어간다. Settings에서 Edit active theme를 클릭한다. 이제 본인이 원하는 색상으로 테마를 꾸미고 아래 Copy theme to clipboard를 눌러 복사한다. 그후 아래와 같이 실행 파일 (.py) 이 있는 곳에 .streamlit 폴더를 생성한 후, co..

import streamlit as st import pandas as pd import plotly.express as px def main(): # 스트림릿에서 제공해주는 차트 # line_chart, area_chart df1 = pd.read_csv('data2/lang_data.csv') st.dataframe(df1) lang_list = df1.columns[1:] choice_list = st.multiselect('언어를 선택하시오', lang_list) if len(choice_list) != 0: df_choice = df1[choice_list] st.dataframe(df_choice) #스트림릿이 제공하는 line_chart st.line_chart(df_choice) # 스트림..

streamlit 라이브러리의 map()을 이용하면 위도, 경도를 받아 지도에 표시해준다. import streamlit as st import pandas as pd def main(): ## 스트림릿의 map 차트 df = pd.read_csv('data2/location.csv', index_col=0) st.dataframe(df) st.map(df) if __name__=='__main__': main()

Streamlit 라이브러리의 plotly_chart() 를 사용하면 된다. import streamlit as st import pandas as pd import plotly.express as px def main(): # plotly 라이브러리를 이용한 차트 그리기. df4 = pd.read_csv('data2/prog_languages_data.csv', index_col=0) st.dataframe(df4) # plotly 의 pie 차트 fig1= px.pie(df4, names='lang', values='Sum', title= '각 언어별 파이차트') st.plotly_chart(fig1) # plotly 의 bar 차트 df4_sorted = df4.sort_values('Sum', a..

Streamlit 라이브러리의 pyplot() 을 이용하면 matplotlib나 seaborn을 이용해 만든 차트를 출력할 수 있다. import streamlit as st import pandas as pd import matplotlib.pyplot as plt import seaborn as sns def main(): st.title('차트 그리기 1') df = pd.read_csv('data2/iris.csv') st.dataframe(df) # 차트 그리기 # sepal_length 와 sepal_width 의 관계를 # 차트로 나타내시오. fig = plt.figure() plt.scatter(data = df, x = 'sepal_length', y = 'sepal_width') plt..

메인으로 쓸 파일에 각각의 파일을 import 해준다. app.py ## 파일을 분리해서 만드는 앱 ## import streamlit as st from app9_about import run_about from app9_eda import run_eda from app9_home import run_home from app9_ml import run_ml def main(): st.title('파일 분리 앱') menu = ['Home', 'EDA', 'ML', 'About'] choice = st.sidebar.selectbox('메뉴', menu) if choice == menu[0] : run_home() elif choice == menu[1] : run_eda() elif choice == ..

사이드바 : streamlit 라이브러리의 sidebar 이용 파일 업로드 : streamlit 라이브러리의 file_uploader() 이용 ##### 파일을 업로드 하는 방법 ##### ##### 이미지 파일, CSV 파일 업로드 import streamlit as st from PIL import Image import pandas as pd import os from datetime import datetime # 디렉토리 정보와 파일을 알려주면, 해당 디렉토리에 # 파일을 저장하는 함수 def save_uploaded_file(directory, file) : # 1.디렉토리가 있는지 확인하여, 없으면 디렉토리부터만든다. if not os.path.exists(directory) : os.mak..

문자 입력 : streamlit 라이브러리의 text_input() 숫자 입력 : streamlit 라이브러리의 number_input() 날짜 입력 : streamlit 라이브러리의 date_input() 시간 입력 : streamlit 라이브러리의 titme_input() 색깔 입력 : streamlit 라이브러리의 color_picker() 비밀번호 입력 : streamlit 라이브러리의 text_input(, type ='password') import streamlit as st def main(): # 유저한테 입력을 받는 방법 # 1. 이름 입력 받기 name = st.text_input('이름을 입력하세요!') if name != '': st.subheader(name + '님 안녕하세요?..

이미지 - streamlit의 image() 함수 import streamlit as st # 이미지 처리를 위한 라이브러리 from PIL import Image def main(): # 1. 저장되어있는 이미지 파일을 화면에 표시하기 img = Image.open('data2/image_03.jpg') st.image(img) # 너비가 화면에 꽉차게 st.image(img, use_column_width= True) if __name__ == '__main__': main() import streamlit as st # 이미지 처리를 위한 라이브러리 from PIL import Image def main(): # 2. 인터넷 상에 있는 이미지를 화면에 표시하기. # URL이 있는 이미지를 말한다. ..