食べログスクレイピング2

抽出数が違うせいかグラフ違う

import pandas as pd
import numpy as np

df = pd.DataFrame(result)
df.describe()

df_osaka = df[df["pref"] == "osaka"]
df_osaka.describe()

df_tokyo = df[df["pref"] == "tokyo"]
df_tokyo.describe()
import matplotlib.pyplot as plt
import seaborn as sns

import japanize_matplotlib

import matplotlib as mpl
mpl.rcParams['figure.dpi'] = 200
# 全国
edges = np.arange(3, 5, 0.02)
ax = df["rate"].plot.hist(title=f"全国の店舗({len(df)})食べログ評価点分布", xlim=(3, 5), width=0.02, color='skyblue', bins=edges)

ax.set_ylabel("店舗数")
ax.set_xlabel("評価点")

ax.axvline(x=3.6, linestyle="--", color="tomato", label='評価点 3.6')
ax.axvline(x=3.8, linestyle="--", color="limegreen", label='評価点 3.8')

plt.show()
# 大阪
ax = df_osaka["rate"].plot.hist(title=f"大阪の店舗({len(df_osaka)})食べログ評価点分布", xlim=(3, 5), width=0.02, color='skyblue', bins=edges)

ax.set_ylabel("店舗数")
ax.set_xlabel("評価点")

ax.axvline(x=3.6, linestyle="--", color="tomato", label='評価点 3.6')
ax.axvline(x=3.8, linestyle="--", color="limegreen", label='評価点 3.8')

plt.show()
# 東京
ax = df_tokyo["rate"].plot.hist(title=f"東京の店舗({len(df_tokyo)})食べログ評価点分布", xlim=(3, 5), width=0.02, color='skyblue', bins=edges)

ax.set_ylabel("店舗数")
ax.set_xlabel("評価点")

ax.axvline(x=3.6, linestyle="--", color="tomato", label='評価点 3.6')
ax.axvline(x=3.8, linestyle="--", color="limegreen", label='評価点 3.8')

plt.show()

f:id:imabari_ehime:20191014212552p:plain

f:id:imabari_ehime:20191014212603p:plain

f:id:imabari_ehime:20191014212612p:plain