LoginSignup
2
3

More than 3 years have passed since last update.

PlotlyとDashで平均気温を可視化

Last updated at Posted at 2020-12-21

これからPlotlyやDashを触る初心者の方にとって、参考になれば幸いです。

自己紹介

分かったこと・できたこと

  • 気象庁からダウンロードしたcsv、扱いにくかった
  • PlotlyとDashで簡単にデータ可視化アプリが作れた

データ

気象庁のページからcsvをダウンロードしてきました。

スクリーンショット 2020-12-22 0.03.51.png

ポチポチ操作してcsvを取得

取得したcsvを手とpandasで加工しました。
スクリーンショット 2020-12-22 0.10.35.png

これを

スクリーンショット 2020-12-22 0.11.44.png

こんなかんじに

ソースコード

例の本を参考に書きました。

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px

import pandas as pd

df = pd.read_csv("./data_processed.csv", engine="python", )
df.set_index("年月日", inplace=True)

app = dash.Dash(__name__)

app.layout = html.Div(
    [
        html.H1("データ可視化 Advent Calendar 20日目", style={"textAlign":"center"}),

        dcc.Graph(
            figure = px.line(df)
        ),

    ]
)

if __name__ == "__main__":
    app.run_server(debug=True)

実行画面

スクリーンショット 2020-12-22 0.39.39.png

まとめと反省

  • 名古屋は(自分のこれまで住んだことのある土地と比較して)暑いなーという感覚は実際あってるみたい。
  • 気象庁のデータもPlotlyとDashの機能もまだまだ持て余してるので今後も勉強を続けて行きたい。
  • 納期ドリブン、失敗しました。すみませんでした...。
2
3
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
2
3