6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

StreamlitでBIしよう!

Posted at

はじめに

Streamlitでドリルダウンを作成することでBIのようなことができる記事を書きました。

今回はPyGWalkerというPythonライブラリをStreamlitで使用していきます。

PyGWalkerとは

以下の記事を参考に二番煎じのようなことをします(;'∀')

PyGWalkerはStreamlitと親和性が高いと公式がおっしゃっています。

ただ、今回はどのようなデータでもBIできるようにスクリプトを作成しました。

スクリプト

import pandas as pd
import pygwalker as pyg
import streamlit.components.v1 as components
import streamlit as st

# Streamlitページの幅を調整する
st.set_page_config(layout="wide")
# タイトルを追加する
st.title("PyGWalker")

# データフレームの用意
df = None

# ファイル選択
with st.sidebar:
    uploaded_files = st.file_uploader("Choose a CSV file", type=["csv"])
    if uploaded_files is not None:
        df = pd.read_csv(uploaded_files)

# pygwalkerで表示
pyg.walk(df, env='Streamlit')
$ streamlit run <アプリ名>

でStreamlitアプリを起動してください。

pyg.png

なんかエラーが出てますが気にしなくてOKです(;´・ω・)
ではcsvファイルを読み込んでみます。
今回は有名なタイタニックのデータを読み込ませます。
tat.png

反映されましたね!!!
あとは左にあるカラム名をX-AxisY-Axisにドラッグアンドドロップすればいいだけです。
必要に応じてフィルタリングなどしてください。

tat.png

今回は参考記事と同じようにグラフを作成してみました。

まとめ

今回はStreamlitでBIを行ってみました!
使い方もめちゃくちゃ簡単です。
詳しくは参考記事をご覧ください!
それでは!!!

6
5
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
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?