Streamlit 12

python(파이썬)의 streamlit(스트림릿)에서 다양한 데이터 차트 그리기 2

스트림릿과 차트그리기에 필요한 라이브러리 import 해줍니다. import streamlit as st import pandas as pd #해당 라이브러리는 설치가 필요합니다. import altair as alt import plotly.express as px 라이브러리 설치는 https://altair-viz.github.io/ Altair: Declarative Visualization in Python — Altair 4.2.0 documentation © Copyright 2016-2020, Altair Developers. altair-viz.github.io https://plotly.com/python/getting-started/ Getting Started Getting Start..

Streamlit 2022.01.10

python(파이썬)의 streamlit(스트림릿)에서 다양한 데이터 차트 그리기 1

스트림릿과 차트그리기에 필요한 라이브러리 import 해줍니다. import streamlit as st import pandas as pd import matplotlib.pyplot as plt import seaborn as sns 스트림릿 화면 출력 함수를 작성해주시고 def main(): pass #pass부분에 작성해주시면 됩니다. if __name__ == '__main__': main() 데이터프레임과 타이틀 이름 정해주기 st.title('Plotting with st.pyplot()') df = pd.read_csv('data/iris.csv') st.dataframe(df.head()) # sepal_length와 sepal_width의 관계를 차트로 그립니다. fig = plt.fi..

Streamlit 2022.01.10

python(파이썬)의 streamlit(스트림릿)에서 클래스를 이용해 py파일 분리하기

스트림릿과 판다스,파일업로드에 필요한 import 해줍니다. import streamlit as st #해당 import는 다른 py파일의 클래스 import 코드입니다. from eda_app import run_eda_app from ML_app import run_ml_app def main(): st.title('파일 분리 앱') menu = ['Home','EDA','ML','About'] choice = st.sidebar.selectbox('메뉴',menu) #사이드바에 메뉴를 선택할 수 있는 박스 만들기 if choice == 'Home': st.subheader('홈 화면입니다.') #Home메뉴 선택시 출력 elif choice =='EDA': run_eda_app() #EDA선택시 해..

Streamlit 2022.01.10

python(파이썬)의 streamlit(스트림릿)에서 여러 파일 업로드

스트림릿과 파일업로드에 필요한 import 해줍니다. import streamlit as st from PIL import Image import os from datetime import datetime # 디렉토리 정보롸 파일을 알려주면 해당 디렉토리에 파일을 저장하는 함수를 만들겁니다. def save_uploaded_file(directory,file): # 1. 디렉토리가 있는지 확인하여 없으면 디렉토리부터 만든다. if not os.path.exists(directory) : os.makedirs(directory) # 2. 디렉토리가 있으니 파일을 저장 with open(os.path.join(directory,file.name), 'wb') as f : f.write(file.getbuff..

Streamlit 2022.01.10

python(파이썬)의 streamlit(스트림릿)에서 파일 업로드 하기

스트림릿과 판다스,파일업로드에 필요한 import 해줍니다. from datetime import datetime 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.makedirs(directory) # 2. 디렉토리가 있으니 파일을 저장 with open(os.path.join(d..

Streamlit 2022.01.10

python(파이썬)의 streamlit(스트림릿) 인터넷창 이름과 아이콘 변경

스트림릿과 판다스를 사용하기 위해 import 해줍니다. import streamlit as st from PIL import Image img = Image.open('이미지 경로와 이름.확장자명') st.set_page_config(page_title='Machine Learning',page_icon=img,layout='wide',initial_sidebar_state='collapsed') def main(): pass if __name__ == '__main__': main() 해당 위에 아이콘과 이름을 변경할 수 있습니다.

Streamlit 2022.01.04

python(파이썬)의 streamlit(스트림릿) 다양한 input 함수들

스트림릿과 판다스를 사용하기 위해 import 해줍니다. import streamlit as st def main(): #작성값 출력 name = st.text_input('이름을 입력하세요. : ') st.title(name) #글자수 최대값 name2 = st.text_input('이름을 입력하세요. : ',max_chars=5) st.title(name2) #긴글 height=3은 3줄만 나옵니다. message = st.text_area('메세지를 입력하세요',height=3) st.text(message) #숫자입력 뒤에 1과 100은 min max값 number = st.number_input('숫자를 입력하세요',1,100) st.text(number) #실수입력 number2 = st.nu..

Streamlit 2022.01.04

python(파이썬)의 streamlit(스트림릿) 이미지, 비디오, 오디오 출력하기

스트림릿과 이미지 출력을 사용하기 위해 import 해줍니다. import streamlit as st import pandas as pd # 이미지 처리를 위한 라이브러리 from PIL import Image def main(): #판다 이미지 img = Image.open('출력할 이미지 경로와 이미지명.확장자명') print(img) st.image(img) st.image(img,use_column_width=True) #사과이미지 링크로 출력 st.image('이미지 주소') #비디오 video_file = open('출력할 비디오 경로와 비디오명.확장자명','rb') st.video(video_file) #오디오 audio_file = open('출력할 오디오 경로와 오디오명.확장자명','r..

Streamlit 2022.01.03

python(파이썬)의 streamlit(스트림릿) button, radio, checkbox, selectbox, multiselect, slider 사용하기

스트림릿을 사용하기 위해 import 해줍니다. from pandas.core.indexing import _iLocIndexer import streamlit as st import pandas as pd def main(): df=pd.read_csv('data/iris.csv') if st.button('데이터 보기'): st.dataframe(df) name = 'Mike' if st.button('대문자로'): st.write(name.upper()) if st.button('소문자로'): st.write(name.lower()) if __name__ == '__main__': main() from pandas.core.indexing import _iLocIndexer import stream..

Streamlit 2022.01.03