회사에서 Dashboard를 요청하게 되어 고민하던 도중 아래와 같이 많은 대시보드 library를 검색하게 되었다.
전사 직원 누구나 어디서든 손쉽게 접근이 가능할 수 있도록이라는 목적에 맞추어 웹 배포가 가능한 Streamlit을 활용하여 구성하도록 결정하였다.
Streamlit은 웹배포가 깃허브 연동 혹은 Docker로 구성이 가능하다.
Python 시각화 라이브러리
- matplotlib
- pandas
- matplolib에 기반한 UI 제공
- matplotlib을 기반으로 여러 색상, 통계용 차트 추가
- Seaborn
- matplotlib을 기반으로 여러 색상, 통계용 차트 추가
- Streamlit
- Web 배포가 가능하며, Dataframe을 기반으로 손쉽게 구현 가능
- 주로 ML에서 데이터를 보기 위해 pyplot과 함께 사용된다.
시각화가 필요한 이유?
Streamlit 설치 및 실행
1
2
| # install
$ pip3 install streamlit
|
1
2
| # execute
$ streamlit run app.py
|
시각화 해보기
1
2
3
| import streamlit as st
st.write(df)
|

Select box
1
| option = st.selectbox('Select Line',second_category.keys())
|

Multi box
1
| option = st.multiselect("Select class", df['col'].unique().tolist()))
|

Line Chart
1
| st.line_chart(df, use_container_width=True)
|

-
Bar
1
2
3
4
5
| bars = alt.Chart(df).mark_bar().encode(
x=alt.X("name"),
y=alt.Y("value")
).properties(title="처음 성공한 매칭의 연결 시간")
st.altair_chart(bars, use_container_width=True)
|


-
line
1
2
3
4
5
6
| lines = alt.Chart(df).mark_line().encode(
x=alt.X('dates'),
y=alt.Y('value'),
color=alt.Color("name")
).properties(title="일별 차트 [cnt-유저수/sum-총합)")
st.altair_chart(lines, use_container_width=True)
|

iframe 연동하기
1
2
3
4
5
6
7
8
| ---
```python
<iframe
src="link"
height="1000"
style="width:100%;border:none;"
></iframe>
```
|