400万行のアクセスログをらくらく分析。
mac にインストール
python3を使うのが楽ぴん。
インストール
pip3 install jupyter pip3 install matplotlib pip3 install pandas
起動
jupyter notebook
実行
1.準備
import matplotlib.pyplot as plt import pandas as pd from pylab import rcParams rcParams['figure.figsize'] = 10, 10 pd.options.display.max_rows = 999
2 読み込み
df = pd.read_csv("data.csv", parse_dates=[0], index_col=[0])
3.処理
# 文字列でフィルタ df2= df.query('url.str.startswith("https://localhost/target")') # index の日付でフィルタ df['2020-04-06 06:00' : '2020-04-06 06:59'].describe() # デイリーで集計 # 最大 df.resample('D').max() # 平均 df.resample('D').mean()