■ 관련 내용 : (EDA) 유가 분석
import matplotlib.pyplot as plt
import seaborn as sns
import platform
from matplotlib import font_manager, rc
get_ipython().run_line_magic('matplotlib', 'inline')
# %matplotlib inline
path = 'C://Windows/Fonts/malgun.ttf'
if platform.system() == 'Darwin':
rc('font', family = 'Arial Unicode MS')
elif platform.system() == 'Windows':
font_name = font_manager.FontProperties(fname = path).get_name()
rc('font', family = font_name)
else:
print('Unknown System.. Sry')
# Boxplot (with Pandas)
stations.boxplot(column = '가격', by = '셀프', figsize = (10, 6))
# boxplot
plt.figure(figsize = (10, 6))
sns.boxplot(x = '상표', y = '가격', hue = '셀프', data = stations, palette = 'Set3')
plt.grid()
plt.show()
import json
import folium
import warnings
warnings.simplefilter(action = 'ignore', category = FutureWarning)
# 가장 비싼 주유소 10개
stations.sort_values(by = '가격', ascending = False).head(10)
# 가장 싼 주유소 10개
stations.sort_values(by = '가격', ascending = True).head(10)
import numpy as np
gu_data = pd.pivot_table(data = stations, index = '구', values = '가격', aggfunc = np.mean)
gu_data.head()
geo_path = 'data/02. skorea_municipalities_geo_simple.json'
geo_str = json.load(open(geo_path, encoding = 'utf-8'))
my_map = folium.Map(
location = [37.5502, 126.982],
zoom_start = 11,
tiles = "Stamen Toner"
)
my_map.choropleth(
geo_data = geo_str,
data = gu_data,
columns = [gu_data.index, '가격'],
key_on = 'feature.id',
fill_color = 'PuRd'
)
my_map