python
๋ซ๊ธฐ#์คํธ๋ฆผ๋ฆฟ์ ๋ด์ฅ ์ฐจํธ ํจ์์ ์ ๋ช
ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ธ plotly ์ฐจํธ
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
import plotly.express as px
def main() :
โโโโ
โโโโ#์คํธ๋ฆผ๋ฆฟ์์ ์ ๊ณตํด์ฃผ๋ ์ฐจํธ
โโโโ#line_chart, area_chart
โโโโdf1 = pd.read_csv('./data/lang_data.csv')
โโโโprint(df1)
โโโโ
โโโโprint(df1.columns[ 1: ])
โโโโ
โโโโcolumn_list = df1.columns[ 1: ]
โโโโchoice_list = st.multiselect('์ธ์ด๋ฅผ ์ ํํ์ธ์', column_list)
โโโโprint(choice_list)
โโโโ
โโโโif len(choice_list) != 0 :
โโโโโโโโdf_choice = df1[choice_list]
โโโโโโโโst.dataframe(df_choice)
โโโโโโโโ
โโโโโโโโst.line_chart(df_choice)
โโโโโโโโst.area_chart(df_choice)
โโโโ
โโโโ
โโโโdf2 = pd.read_csv('./data/iris.csv')
โโโโdf_iris = df2.iloc[ : , 0:-2+1 ]
โโโโ
โโโโ#์คํธ๋ฆผ๋ฆฟ์ด ์ ๊ณตํ๋ bar_chart
โโโโst.bar_chart(df_iris)
โโโโ
โโโโ
โโโโdf3 = pd.read_csv('./data/location.csv')
โโโโprint(df3)
โโโโ
โโโโst.map(df3)
โโโโ
โโโโdf4 = pd.read_csv('./data/prog_languages_data.csv', index_col=0)
โโโโprint(df4)
โโโโ
โโโโ#plotly ์ pie ์ฐจํธ
โโโโfig1 = px.pie(data_frame= df4, names='lang', values='Sum', title='๊ฐ ์ธ์ด๋ณ ํ์ด์ฐจํธ')
โโโโst.plotly_chart(fig1)
โโโโ
โโโโ#plotly ์ bar ์ฐจํธ
โโโโprint( df4.sort_values('Sum') )
โโโโdf_sorted = df4.sort_values('Sum')
โโโโfig2 = px.bar(data_frame=df_sorted, x='lang', y='Sum')
โโโโst.plotly_chart(fig2)
โโโโ
โโโโdf_sorted2 = df4.sort_values('Sum', ascending=False)
โโโโ
โโโโfig3 = px.bar(df_sorted2, x='lang', y='Sum')
โโโโst.plotly_chart(fig3)
โโโโ
if __name__ == '__main__' :
โโโโmain()






'Python > Matplotlib' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
scatter, histogram ๋ฑ์ ์ฐจํธ๋ฅผ ์คํธ๋ฆผ๋ฆฟ(streamlit)์ผ๋ก ํํํ๊ธฐ (0) | 2024.04.26 |
---|---|
Matplotlib) Scatter(์ค์บํฐ) ์ฐจํธ์ HeatMap(ํํธ๋งต) ๊ทธ๋ฆฌ๊ธฐ (0) | 2024.04.16 |
Matplotlib) Histograms(ํ์คํ ๊ทธ๋จ) ์ฐจํธ ๊ทธ๋ฆฌ๊ธฐ (0) | 2024.04.15 |
Matplotlib) Pie (ํ์ด) ์ฐจํธ ๊ทธ๋ฆฌ๊ธฐ (0) | 2024.04.15 |
Matplotlib) Bar chart : countplot ์ฐจํธ ๊ทธ๋ฆฌ๊ธฐ (0) | 2024.04.15 |