LoginSignup
0
1

More than 1 year has passed since last update.

40代おっさんStreamlitを学ぶ

Posted at

本記事について

この記事はプログラミング初学者の私が学んでいく中でわからない単語や概要を分かりやすくまとめたものです。
もし不正などありましたらコメントにてお知らせいただければ幸いです。

Streamlit

treamlitとは、PythonでWebアプリケーションを作成するためのフレームワークです。

データサイエンティストやAIエンジニア向けに開発されており、バックエンド開発の知識がなくてもPythonのコードを数行書くだけで、気軽にデモ用のアプリを作成することができるのが特徴です。

Streamlitインストール

pip3 install streamlit

確かめる

streamlit hello

自分ははじめてだったのでメールアドレス求められました。

サイトにアクセスできれば大丈夫です。

Text elements

フォルダを作り
app.pyを作成

import streamlit as st
st.write('利樹大好き')

streamlitを実行

streamlit run app.py

ダブルコーテーションでも文字が表示できます。(Magic)

import streamlit as st
st.write('利樹大好き')
"利樹大好きだよ~~ン"
import streamlit as st
st.title('利樹が大好きすぎる件について') # タイトル
st.markdown('## 利樹が大好きすぎる件について') # マークダウン記法

st.code('a = 123', language='python') # コード記法

Data display elements

import streamlit as st
import pandas as pd

csv = pd.read_csv('dummy.csv') # csv読み込み適当なの入れました

df = pd.DataFrame(csv)

st.dataframe(df) # streamlitにてWEB上に

json

import streamlit as st
import pandas as pd

csv = pd.read_csv('dummy.csv') # csv読み込み適当なの入れました

df = pd.DataFrame(csv)

st.dataframe(df) # streamlitにてWEB上に

json = df.to_json(orient="records") # ヘッダーがある場合

st.json(json) # jsonデータを表示

Chart elements

import streamlit as st
import pandas as pd
import numpy as np

df = pd.DataFrame(
    np.random.randn(20, 3),
    columns=['a', 'b', 'c']
)

st.line_chart(df)

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1