Kepler.glをJupyterNotebook上で扱ってみた

Kepler.glをJupyterNotebook上で扱ってみます.

# ライブラリのインストール

下記のコードでライブラリをインストールします.

!pip install keplergl
!pip install geopandas
!pip install sodapy
!jupyter labextension install @jupyter-widgets/jupyterlab-manager keplergl-jupyter

# サンプルデータのダウンロード

加古川市_公用車走行データ (opens new window)より、2017年のcsvデータをダウンロードします。

# コードの実行

下記のコードでデータを読み込みます.

from keplergl import KeplerGl
import pandas as pd
import base64

df = pd.read_csv('../kakogawa_probe_2017/probe_kaisen081_2017.csv.csv',
                 header = None ,
                 names=['car_id', 'record_time','lat','lon'])

下記のコードでkeplerを表示します.

HTMLが出力されるので,jupyterで読み込みます.

# データの読み込み
map1 = KeplerGl(height=400)
map1.add_data(data=df, name='data1')

# htmlで表記
orig_html = str(map1._repr_html_(),'utf-8')
b64d_html = base64.b64encode(orig_html.encode('utf-8')).decode('utf-8')
framed_html = f'<iframe src="data:text/html;base64,{b64d_html}" style="width:95%; height: 600px">'

import IPython
IPython.display.HTML(framed_html)

# まとめ

Kepler.glをJupyterNotebook上で扱ってみました.

# 参考サイト

Kepler.glをJupyterNotebook上で扱ってみた (opens new window)

bindings/kepler.gl-jupyter (opens new window)

Using Kepler.GL in Jupyter (opens new window)

kepler.gl for Jupyter User Guide (opens new window)

加古川市_公用車走行データ (opens new window)

[小ネタ001]PandasとBig Queryを連携させる

[小ネタ001]PandasとBig Queryを連携させる

PandasとBig Queryを連携させます.

PythonでBig Queryを操作する

PythonでBig Queryを操作する

PythonでBig Queryを操作します.