Business District Analysis by Sangho Suh

Table of Contents

I. Introduction

  • Abstract
  • Environment Setting

II. Exploratory Data Analysis (EDA)

  • Data Wrangling
  • Hypothesis Formulation

III. Hypothesis Testing

  • Data Visualization

VI. Conclusion

NOTE: 'A' in the beginning of comment indicates 'Analysis', while 'E' indicates 'Explanation.' 'Note' is a side note and thus NOT a critical part of the assignment.

I. Introduction

  • Abstract

The goal of this assignment is to explore the given dataset and combine it with public dataset of our choice to hypothesize a claim and test it.

  • Environment Setting
In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

II. Exploratory Data Analysis (EDA)

  • Data Wrangling

Let's visualize dataset to understand it

Note: One problem encountered was that Korean characters come broken when pandas.read_csv() is used. This is due to the fact that read_csv() does not use encoding('UTF-8') as default, which is needed for properly displaying Korean characters After displaying them using the following code, 'data wrangling' (or a.k.a 'data munging') was required to properly use district names in the later part of this assignment.

In [2]:
# reference
# http://freeprog.tistory.com/10

import codecs
import csv

# unicode_csv_reader(), utf_8_encoder()  
#     --->  https://docs.python.org/2/library/csv.html 에서 제공함.

def unicode_csv_reader(unicode_csv_data, dialect=csv.excel, **kwargs):
    # csv.py doesn't do Unicode; encode temporarily as UTF-8:
    csv_reader = csv.reader(utf_8_encoder(unicode_csv_data),
                            dialect=dialect, **kwargs)
    for row in csv_reader:
        # decode UTF-8 back to Unicode, cell by cell:
        yield [unicode(cell, 'utf-8') for cell in row]
 
def utf_8_encoder(unicode_csv_data):
    for line in unicode_csv_data:
        yield line.encode('utf-8')  
        
data = []
  
with codecs.open('1_total.csv','r', encoding = 'euc-kr') as csvf:
    rd = unicode_csv_reader(csvf)
    t = next(rd)
    for fieldname in t:
        print fieldname,
        
    print
        
    for idx, data in enumerate(rd):
        print idx, data[0], data[1], data[2] 
province city total category
0 서울특별시 강남구 38476 
1 서울특별시 서초구 23099 
2 서울특별시 송파구 19646 
3 서울특별시 영등포구 17657 
4 서울특별시 중구 17627 
5 서울특별시 마포구 16067 
6 서울특별시 종로구 15648 
7 서울특별시 강동구 14585 
8 서울특별시 강서구 14574 
9 서울특별시 양천구 14154 
10 서울특별시 노원구 13777 
11 서울특별시 광진구 13254 
12 서울특별시 구로구 13167 
13 서울특별시 관악구 13094 
14 서울특별시 은평구 12545 
15 서울특별시 용산구 12531 
16 서울특별시 성동구 12489 
17 서울특별시 동대문구 12058 
18 서울특별시 동작구 12055 
19 서울특별시 성북구 11488 
20 서울특별시 중랑구 10888 
21 서울특별시 서대문구 10814 
22 서울특별시 금천구 10611 
23 서울특별시 도봉구 9758 
24 서울특별시 강북구 9621 

Let's read Data

In [3]:
# Read data
df_total = pd.read_csv('1_total.csv')
df_top_business = pd.read_csv('1_top_business.csv')

df_medical = pd.read_csv('1_medical.csv')
df_education = pd.read_csv('1_education.csv')
df_food = pd.read_csv('1_food.csv')
df_wholesale = pd.read_csv('1_wholesale.csv')
df_service = pd.read_csv('1_service.csv')

What does it look like?

In [4]:
df_total.head()
Out[4]:
province city total category
0 ����Ư���� ������ 38476 ��ü
1 ����Ư���� ���ʱ� 23099 ��ü
2 ����Ư���� ���ı� 19646 ��ü
3 ����Ư���� �������� 17657 ��ü
4 ����Ư���� �߱� 17627 ��ü
In [5]:
total_lst = df_total['total'].tolist()
top_business_lst = df_top_business['total'].tolist()

# Individual sectors are as follows
medical_lst = df_medical['total'].tolist()
education_lst = df_education['total'].tolist()
food_lst = df_food['total'].tolist()
wholesale_lst = df_wholesale['total'].tolist()
service_lst = df_service['total'].tolist()

Let's gain insights about data through statistics and visualizations

In [6]:
# Brief statistics

print 'Overview\n'
print 'Max: ' + str(df_total['total'].max())
print 'Min: ' + str(df_total['total'].min())
print 'Max - Min: ' + str( df_total['total'].max() - df_total['total'].min() )
print 'Average: ' + str(int(df_total['total'].mean()))
print 'Standard deviation: ' + str( int(df_total['total'].std()) )
sixty_five_percent = [int(df_total['total'].mean() + df_total['total'].std()), int(df_total['total'].mean() - df_total['total'].std())]
ninety_five_percent = [int(df_total['total'].mean() + 2*df_total['total'].std()), int(df_total['total'].mean() - 2*df_total['total'].std())]
print '65% range: ' + str(sixty_five_percent) + ' (one standard deviation)'
print '95% range: ' + str(ninety_five_percent) + ' (two standard deviation)'
Overview

Max: 38476
Min: 9621
Max - Min: 28855
Average: 14787
Standard deviation: 5857
65% range: [20644, 8929] (one standard deviation)
95% range: [26502, 3071] (two standard deviation)
In [7]:
plt.hist(total_lst,bins=100)
plt.xlabel('Revenue (Won)')
plt.ylabel('Frequency')
plt.title(r'$\mathrm{Total\ Revenue\ Distribution:}\ \mu=14787,\ \sigma=5857$')
plt.axis([5000, 40000, 0, 4])

plt.show()

A: The above histogram shows that there is great polarization (양극화) on highest earning district ('kangnam') and less earning districts--note one bar in the range (35000,40000) and the rest in the range (7000,25000).

In [8]:
print 'Total number of districts: ' + str(len(total_lst))
Total number of districts: 25
In [9]:
top_6_dists = 0
bottom_19_dists = 0

for i in range(0,6):
    top_6_dists = top_6_dists + top_business_lst[i]
    
for j in range(7,25):
    bottom_19_dists = bottom_19_dists + top_business_lst[j]
    
print 'Revenue by top 6 districtss:    ' + str(top_6_dists)
print 'Revenue by bottom 19 districts: ' + str(bottom_19_dists)
Revenue by top 6 districtss:    52169
Revenue by bottom 19 districts: 53149

A: This illustrates that top 6 districts make as much as the remaining 19 districts

Let's see which business sectors contribute the most on these districts

In [10]:
print
print
print 'Get data before visualizing to identify which business contributes the most\n'

print 'Education Max: ' + str(df_education['total'].max())
print 'Education Min: ' + str(df_education['total'].min())
print
print 'Medical Max: ' + str(df_medical['total'].max())
print 'Medical Min: ' + str(df_medical['total'].min())
print
print 'Food Max: ' + str(df_food['total'].max())
print 'Food Min: ' + str(df_food['total'].min())
print
print 'Wholesale Max: ' + str(df_wholesale['total'].max())
print 'Wholesale Min: ' + str(df_wholesale['total'].min())

Get data before visualizing to identify which business contributes the most

Education Max: 6486
Education Min: 977

Medical Max: 23442
Medical Min: 3901

Food Max: 17872
Food Min: 4988

Wholesale Max: 22154
Wholesale Min: 6087

A: From the above, we can see that medical sector is the highest earning sector, followed by wholesale, food, and education sector.

In [11]:
from numpy import array
In [12]:
# create multi-dimensional matrix which is the format we need for visualizing in histogram

multi_lst = [education_lst,medical_lst,food_lst,wholesale_lst,service_lst]
arr = array(multi_lst)
arr = np.transpose(arr)
In [13]:
n_bins = 10

fig, axes = plt.subplots(nrows=1, ncols=2,figsize=(10,5))
ax0, ax1 = axes.flat

colors = ['red', 'grey', 'lime','blue','yellow']
labels = ['education','medical','food','wholesale','service']

ax0.hist(arr, n_bins, normed=0, histtype='bar', color=colors, label=labels)
ax0.set_xlabel('Revenue (won)')
ax0.set_ylabel('Frequency')
ax0.legend(prop={'size': 10})
ax0.set_title('Sector distribution')

ax1.hist(arr, n_bins, normed=0, histtype='bar', stacked=True)
ax1.set_xlabel('Revenue (won)')
ax1.set_ylabel('Frequency')
ax1.set_title('Stacked bar (extension from \'Sector distribution\')')

plt.tight_layout(pad=0.8, w_pad=0.8, h_pad=1.0)
plt.show()

E: The histogram above on the left demonstrates 'sector distribution.'

A: From 'sector distribution,' we can see that 'education (red)', 'service (yellow)' sectors are concentrated in lower ange than other sectors. Generally speaking, the top two sectors that seem to belong to higher revenue range are 'wholesale (blue)' and 'food (green).' The 'medical (grey)' sector seemes to be in-between.

A: The histogram on the right ('Stacked bar' histogram) makes it clear that most of the revenues are less than 15,000 won.

Note that we have not analyzed individual districts yet. Let's see what kind of insights we can get from them.

Note: As mentioned in the early part of assignment, Korean characters are broken in IPython Notebook. Solutions were sought after, but after several attempts with no significant success, I had to resort to 'hard-coding' the list of districts in order to save time (as shown below).

In [14]:
# since the ordering of districts are different for each business sector, I hard-coded the list of districts

dist_total_section = ['kangnam','seocho','songpa','yeongdeungpo','jung','mapo','jongro','kangdong','kangseo','yangcheon','nowon','kwangjin','guro','kwanak','eunpyeong','yongsan','seongdong','dongdaemun','dongjak','seongbuk','joongrang','seodaemun','geumcheon','dobong','kangbuk']
dist_service_section = ['kangnam','seocho','songpa','mapo','kangseo','yeongdeungpo','kwanak','kwangjin','kangdong','jung','nowon','guro','yangcheon','seodaemun','eunpyeong','dongjak','seongbuk','joongrang','jongro','dongdaemun','kangbuk','seongdong','yongsan','geumcheon','dobong']
dist_food_section = ['kangnam','seocho','jung','jongro','mapo','yeongdeungpo','songpa','yongsan','kangseo','kangdong','kwanak','kwangjin','yangcheon','nowon','guro','dongjak','dongdaemun','seodaemun','eunpyeong','seongbuk','seongdong','geumcheon','joongrang','kangbuk','dobong']
dist_wholesale_section = ['kangnam','seocho','yeongdeungpo','jung','jongro','seongdong','mapo','yangcheon','kangseo','kangdong','guro','nowon','kwangjin','eunpeyong','dongdaemun','yongsan','dongjak','joongrang','geumcheon','seongbuk','kwanak','dobong','seodaemun','kangbuk']
dist_medical_section = ['kangnam','seocho','songpa','yeongdeungpo','kangdong','mapo','nowon','kwanak','kangseo','yangcheon','eunpyeong','jung','dongjak','guro','dongdaemun','jongro','seongbuk','kwangjin','seodaemun','seongdong','joongrang','yongsan','kangbuk','geumcheon','dobong']
dist_education_section = ['kangnam','seocho','yangcheon','songpa','nowon','kangseo','kangdong','mapo','dongjak','eunpyeong','yeongdeungpo','seodaemun','dongdaemun','kwangjin','kwanak','seongbuk','guro','jongro','dobong','yongsan','joongrang','seongdong','kangbuk','geumcheon','jung']

Let's transform this into matrix format which makes it easier for us to manipulate

In [15]:
# put lists into list
districts = [dist_service_section, dist_food_section, dist_wholesale_section, dist_medical_section, dist_education_section]
# transform list into numpy.array
np_dists = np.array(districts)

Let's define a function that allows us to see top n districts in terms of total revenue and each sectors' revenue

In [16]:
def print_top_districts(num):
    print 'Total Revenue \n' + str(dist_total_section[0:num])
    print
    print 'Service \n' + str(np_dists[0][0:num])
    print 'Food \n' + str(np_dists[1][0:num])
    print 'Wholesale \n' + str(np_dists[2][0:num])
    print 'Medical \n' + str(np_dists[3][0:num])
    print 'Education \n' + str(np_dists[4][0:num])
In [17]:
# check top n districts in terms of total revenue and each sectors' revenue
print_top_districts(7)
Total Revenue 
['kangnam', 'seocho', 'songpa', 'yeongdeungpo', 'jung', 'mapo', 'jongro']

Service 
['kangnam', 'seocho', 'songpa', 'mapo', 'kangseo', 'yeongdeungpo', 'kwanak']
Food 
['kangnam', 'seocho', 'jung', 'jongro', 'mapo', 'yeongdeungpo', 'songpa']
Wholesale 
['kangnam', 'seocho', 'yeongdeungpo', 'jung', 'jongro', 'seongdong', 'mapo']
Medical 
['kangnam', 'seocho', 'songpa', 'yeongdeungpo', 'kangdong', 'mapo', 'nowon']
Education 
['kangnam', 'seocho', 'yangcheon', 'songpa', 'nowon', 'kangseo', 'kangdong']

One information we have not looked at yet is top business (and its associated area). Let's take a look at it in order to finally formulate hypothesis from the insights gathered so far.

In [18]:
# reference
# http://freeprog.tistory.com/10

import codecs
import csv

# unicode_csv_reader(), utf_8_encoder()  
#     --->  https://docs.python.org/2/library/csv.html 에서 제공함.

def unicode_csv_reader(unicode_csv_data, dialect=csv.excel, **kwargs):
    # csv.py doesn't do Unicode; encode temporarily as UTF-8:
    csv_reader = csv.reader(utf_8_encoder(unicode_csv_data),
                            dialect=dialect, **kwargs)
    for row in csv_reader:
        # decode UTF-8 back to Unicode, cell by cell:
        yield [unicode(cell, 'utf-8') for cell in row]
 
def utf_8_encoder(unicode_csv_data):
    for line in unicode_csv_data:
        yield line.encode('utf-8')  
        
data = []
  
with codecs.open('1_top_business.csv','r', encoding = 'euc-kr') as csvf:
    rd = unicode_csv_reader(csvf)
    t = next(rd)
    for fieldname in t:
        print fieldname,
        
    print
        
    for idx, data in enumerate(rd):
        print idx, data[0], data[1], data[2], data[3], data[4], data[5]
province city area_name business_type total rank
0 서울특별시 강남구 강남역 아래 컴퓨터/주변기기 13598  1
1 서울특별시 강남구 압구정역 성형외과 11123  2
2 서울특별시 강남구 강남역 위 성형외과 9635  3
3 서울특별시 종로구 종각역 인근 서적/도서 6393  1
4 서울특별시 강남구 신사 논현역 성형외과 6140  4
5 서울특별시 종로구 광화문역 인근 서적/도서 5280  2
6 서울특별시 성동구 성수역주변 문구/팬시 4242  1
7 서울특별시 강남구 학동사거리 부근 성형외과 3931  5
8 서울특별시 강남구 강남역 위 치과 3895  6
9 서울특별시 강남구 강남역 위 피부과 3631  7
10 서울특별시 마포구 마포역 잡화 3561  1
11 서울특별시 구로구 고대구로병원사거리 인근 꽃집 3441  1
12 서울특별시 성동구 성수역주변 슈퍼마켓(일반) 3371  2
13 서울특별시 강남구 압구정역 치과 3314  8
14 서울특별시 종로구 종각역 인근 한정식 3036  3
15 서울특별시 강남구 강남역 아래 치과 2986  9
16 서울특별시 용산구 한남동 꽃집 2700  1
17 서울특별시 강남구 압구정역 피부과 2668  10
18 서울특별시 금천구 협진교차로 인근 슈퍼마켓(일반) 2555  1
19 서울특별시 관악구 서울대역 주변상권 일반병원 2505  1
20 서울특별시 노원구 노원역 일반병원 2410  1
21 서울특별시 강동구 고덕역인근 슈퍼마켓(일반) 2326  1
22 서울특별시 서초구 교대역 치과 2317  1
23 서울특별시 종로구 종각역 인근 치과 2274  4
24 서울특별시 서초구 서울교대역-남부터미널역주변지역 자동차경정비 2228  2
25 서울특별시 성동구 성수역주변 자동차경정비 2199  3
26 서울특별시 서초구 반포_고속터미널주변 주유소 2165  3
27 서울특별시 강동구 천호역 슈퍼마켓(일반) 2071  2
28 서울특별시 서초구 서울교대역-남부터미널역주변지역 주유소 2063  4
29 서울특별시 서초구 교대역 대입학원 2023  5
30 서울특별시 관악구 서울대역 주변상권 치과 2017  2
31 서울특별시 중구 신당, 동대문 운동장역 부근 이동통신 2010  1
32 서울특별시 노원구 중계그린공원앞 슈퍼마켓(일반) 1982  2
33 서울특별시 종로구 안국역 인근 한정식 1968  5
34 서울특별시 성동구 답십리역-용답역주변 일반병원 1960  4
35 서울특별시 노원구 노원역 피부과 1959  3
36 서울특별시 구로구 구로디지털공단역 인근 일반병원 1942  2
37 서울특별시 강동구 천호역 치과 1941  3
38 서울특별시 동작구 사당역 치과 1866  1
39 서울특별시 종로구 종각역 인근 분식 1866  6
40 서울특별시 서초구 교대역 한정식 1862  6
41 서울특별시 중구 서울역 회현역 주변 안경 1854  2
42 서울특별시 금천구 시흥유통상가 자동차경정비 1848  2
43 서울특별시 송파구 삼전동 자동차경정비 1840  1
44 서울특별시 중구 신당, 동대문 운동장역 부근 남성의류 1838  3
45 서울특별시 중구 신당, 동대문 운동장역 부근 편의점 1837  4
46 서울특별시 강서구 가양동 슈퍼마켓(일반) 1789  1
47 서울특별시 도봉구 창동역 슈퍼마켓(일반) 1782  1
48 서울특별시 서대문구 신촌역 치과 1761  1
49 서울특별시 종로구 종각역 인근 정통호프 1734  7
50 서울특별시 종로구 종각역 인근 스테이크 전문점 1719  8
51 서울특별시 마포구 마포역 치과 1711  2
52 서울특별시 영등포구 영등포 시장역 인근 일반병원 1698  1
53 서울특별시 서대문구 신촌역 피부과 1685  2
54 서울특별시 중구 명동역 주변 남성의류 1671  5
55 서울특별시 서초구 방배동_내방역북쪽지역 자동차경정비 1666  7
56 서울특별시 중구 명동역 주변 일반의류 1657  6
57 서울특별시 종로구 종각역 인근 편의점 1634  9
58 서울특별시 노원구 노원역 성형외과 1628  4
59 서울특별시 서초구 서울교대역-남부터미널역주변지역 한정식 1620  8
60 서울특별시 서초구 서울교대역-남부터미널역주변지역 치과 1616  9
61 서울특별시 서초구 총신대 치과 1606  10
62 서울특별시 중구 을지로4가역 인근 조명/전기용품 1606  7
63 서울특별시 종로구 광화문역 인근 한정식 1602  10
64 서울특별시 노원구 수락산역 가전제품 1598  5
65 서울특별시 금천구 시흥유통상가 슈퍼마켓(일반) 1587  3
66 서울특별시 송파구 잠실역 치과 1581  2
67 서울특별시 노원구 노원역 치과 1576  6
68 서울특별시 관악구 신림역 주변상권 치과 1567  3
69 서울특별시 중구 명동역 주변 피부과 1564  8
70 서울특별시 양천구 목6단지 패밀리레스토랑 1560  1
71 서울특별시 구로구 고척공구상가 남성의류 1560  3
72 서울특별시 송파구 신천역 일반병원 1546  3
73 서울특별시 송파구 신천역 치과 1511  4
74 서울특별시 중랑구 중량위딩, 우림시장 가전제품 1509  1
75 서울특별시 동작구 노량진 주유소 1501  2
76 서울특별시 동작구 사당역 한정식 1500  3
77 서울특별시 광진구 구의역 일반병원 1499  1
78 서울특별시 강동구 길동역 일반병원 1492  4
79 서울특별시 용산구 용산역앞 약국 1484  2
80 서울특별시 용산구 용산전자 인근 컴퓨터/주변기기 1479  3
81 서울특별시 서대문구 신촌역 약국 1474  3
82 서울특별시 중구 명동역 주변 치과 1466  9
83 서울특별시 마포구 홍대입구역 치과 1452  3
84 서울특별시 용산구 이태원 스테이크 전문점 1452  4
85 서울특별시 강북구 수유역 치과 1442  1
86 서울특별시 서대문구 신촌역 한정식 1438  4
87 서울특별시 마포구 홍대입구역 한정식 1416  4
88 서울특별시 마포구 마포역 한정식 1414  5
89 서울특별시 중구 을지로4가역 인근 한정식 1414  10
90 서울특별시 마포구 홍대입구역 남성의류 1389  6
91 서울특별시 서대문구 신촌역 일반병원 1387  5
92 서울특별시 양천구 목동역2 대입학원 1382  2
93 서울특별시 동작구 사당역 주유소 1380  4
94 서울특별시 동작구 사당역 가전제품 1380  5
95 서울특별시 광진구 잠실대교북단 주유소 1377  2
96 서울특별시 송파구 잠실역 자동차경정비 1371  5
97 서울특별시 마포구 합정역 일반의류 1369  7
98 서울특별시 구로구 구로디지털공단역 인근 자동차경정비 1368  4
99 서울특별시 영등포구 영등포 시장역 인근 한정식 1357  2
100 서울특별시 송파구 잠실역 한정식 1356  6
101 서울특별시 관악구 신림역 주변상권 한정식 1356  4
102 서울특별시 중랑구 상봉역 자동차경정비 1353  2
103 서울특별시 서대문구 신촌역 성형외과 1343  6
104 서울특별시 양천구 목동역1 치과 1342  3
105 서울특별시 송파구 신천역 한정식 1334  7
106 서울특별시 노원구 공릉역 자동차경정비 1320  7
107 서울특별시 송파구 가락시장역부근 일반의류 1319  8
108 서울특별시 강서구 가양사거리 주유소 1301  2
109 서울특별시 은평구 연신내역 치과 1278  1
110 서울특별시 성동구 왕십리역-상왕십리역주변 치과 1275  5
111 서울특별시 송파구 삼전동 치과 1272  9
112 서울특별시 용산구 남영동 잡화 1267  5
113 서울특별시 송파구 삼전동 분식 1266  10
114 서울특별시 관악구 서울대역 주변상권 한정식 1263  5
115 서울특별시 성동구 성수역주변 치과 1257  6
116 서울특별시 동작구 신대방삼거리역 남성의류 1250  6
117 서울특별시 노원구 공릉역 가전제품 1246  8
118 서울특별시 서대문구 신촌역 정통호프 1235  7
119 서울특별시 성동구 성수역주변 한정식 1230  7
120 서울특별시 강동구 길동역 룸/단란주점 1227  5
121 서울특별시 노원구 수락산역 잡화 1227  9
122 서울특별시 영등포구 신대방역 북측 주변 자동차경정비 1214  3
123 서울특별시 도봉구 창동역 가전제품 1212  2
124 서울특별시 마포구 홍대입구역 편의점 1211  8
125 서울특별시 양천구 스포츠조선뒤 슈퍼마켓(일반) 1201  4
126 서울특별시 용산구 남영동 분식 1200  6
127 서울특별시 광진구 건대입구역 정통호프 1197  3
128 서울특별시 구로구 구로5동 사거리 인근 서적/도서 1188  5
129 서울특별시 마포구 홍대입구역 정통호프 1181  9
130 서울특별시 동작구 사당역 정통호프 1175  7
131 서울특별시 양천구 목6단지 대입학원 1163  5
132 서울특별시 영등포구 영등포 시장역 인근 치과 1156  4
133 서울특별시 강동구 천호역 피부과 1154  6
134 서울특별시 강동구 고덕역인근 치과 1151  7
135 서울특별시 강서구 강서구청 주변 치과 1145  3
136 서울특별시 구로구 개봉본동 인근 가전제품 1141  6
137 서울특별시 관악구 서울대역 주변상권 편의점 1139  6
138 서울특별시 중랑구 중량위딩, 우림시장 치과 1135  3
139 서울특별시 노원구 노원역 한정식 1134  10
140 서울특별시 영등포구 영등포구청역 인근 자동차경정비 1132  5
141 서울특별시 영등포구 영등포 시장역 인근 분식 1130  6
142 서울특별시 양천구 오목교역 치과 1130  6
143 서울특별시 강동구 길동역 치과 1129  8
144 서울특별시 관악구 신림역 주변상권 화장품 1125  7
145 서울특별시 강북구 수유역 주유소 1121  2
146 서울특별시 용산구 이태원 한정식 1119  7
147 서울특별시 성북구 성심여대역 치과 1119  1
148 서울특별시 관악구 신림역 주변상권 정통호프 1115  8
149 서울특별시 동작구 노량진 분식 1114  8
150 서울특별시 관악구 신림역 주변상권 분식 1108  9
151 서울특별시 성동구 성수역주변 분식 1107  8
152 서울특별시 양천구 스포츠조선뒤 자동차경정비 1099  7
153 서울특별시 성동구 뚝섬역주변 주유소 1099  9
154 서울특별시 용산구 이태원 스포츠/등산용품 1088  8
155 서울특별시 영등포구 영등포 시장역 인근 피부과 1087  7
156 서울특별시 강서구 화곡역 치과 1083  4
157 서울특별시 관악구 신림역 주변상권 편의점 1082  10
158 서울특별시 은평구 불광역 치과 1075  2
159 서울특별시 서대문구 신촌역 대입학원 1073  8
160 서울특별시 서대문구 신촌역 편의점 1072  9
161 서울특별시 강서구 화곡역 일반병원 1064  5
162 서울특별시 성동구 답십리역-용답역주변 주유소 1060  10
163 서울특별시 양천구 목동로데오거리 일반병원 1058  8
164 서울특별시 구로구 고대구로병원사거리 인근 약국 1056  7
165 서울특별시 광진구 군자역 치과 1055  4
166 서울특별시 서대문구 이대역 여성미용실 1052  10
167 서울특별시 금천구 독산사거리 인근 치과 1051  4
168 서울특별시 강북구 미아8동 가전제품 1048  3
169 서울특별시 강동구 둔촌동역 치과 1048  9
170 서울특별시 금천구 독산본동 인근 정형외과 1033  5
171 서울특별시 강서구 강서구청 주변 정통호프 1028  6
172 서울특별시 강서구 가양동 일반병원 1027  7
173 서울특별시 강동구 천호역 일반병원 1026  10
174 서울특별시 구로구 디지털 단지앞 상가 지역 일반의류 1023  8
175 서울특별시 동작구 해군회관앞 주유소 1013  9
176 서울특별시 양천구 스포츠조선뒤 치과 1012  9
177 서울특별시 구로구 구로디지털공단역 인근 한정식 1010  9
178 서울특별시 강서구 발산역 패밀리레스토랑 1009  8
179 서울특별시 마포구 홍대입구역 커피전문점 1005  10
180 서울특별시 성북구 성심여대역 피부과 1004  2
181 서울특별시 강서구 강서구청 주변 한정식 996  9
182 서울특별시 금천구 금천구청 인근 치과 995  6
183 서울특별시 광진구 건대입구역 한정식 994  5
184 서울특별시 강서구 화곡역 피부과 993  10
185 서울특별시 동대문구 청량리역 한방병원 991  1
186 서울특별시 광진구 올림픽대교북단 치과 988  6
187 서울특별시 용산구 한남동 치과 988  9
188 서울특별시 영등포구 영등포 시장역 인근 자동차경정비 984  8
189 서울특별시 구로구 구로구청사거리 및 대림역 인근 가전제품 980  10
190 서울특별시 영등포구 영등포 시장역 인근 정통호프 979  9
191 서울특별시 은평구 연신내역 한정식 978  3
192 서울특별시 영등포구 영등포구청역 인근 분식 978  10
193 서울특별시 강북구 미아3동 치과 964  4
194 서울특별시 동작구 노량진 대입학원 964  10
195 서울특별시 은평구 은평구청 가전제품 961  4
196 서울특별시 중랑구 중량위딩, 우림시장 주유소 959  4
197 서울특별시 양천구 등촌사거리 치과 947  10
198 서울특별시 도봉구 창동역 치과 938  3
199 서울특별시 용산구 용산전자 인근 슈퍼마켓(일반) 934  10
200 서울특별시 강북구 미아삼거리역 치과 926  5
201 서울특별시 광진구 건대입구역 치과 916  7
202 서울특별시 강북구 수유역 정통호프 909  6
203 서울특별시 금천구 금천구청 인근 한정식 907  7
204 서울특별시 강북구 수유역 한정식 898  7
205 서울특별시 성북구 한성대입구역 가전제품 896  3
206 서울특별시 광진구 구의역 치과 882  8
207 서울특별시 광진구 올림픽대교북단 내과 876  9
208 서울특별시 강북구 미아삼거리역 일반병원 854  8
209 서울특별시 강북구 수유역 일반병원 848  9
210 서울특별시 은평구 구산역 치과 834  5
211 서울특별시 광진구 건대입구역 분식 834  10
212 서울특별시 강북구 미아역 치과 827  10
213 서울특별시 동대문구 청량리역 정육점 811  2
214 서울특별시 은평구 은평구청 주유소 804  6
215 서울특별시 금천구 금천구청 인근 차량물품/인테리어 792  8
216 서울특별시 은평구 연신내역 꽃집 790  7
217 서울특별시 중랑구 사가정역 치과 785  5
218 서울특별시 은평구 구산역 피부과 784  8
219 서울특별시 은평구 연신내역 피부과 784  9
220 서울특별시 은평구 신사오거리 치과 782  10
221 서울특별시 중랑구 중화역 주변 상권 치과 780  6
222 서울특별시 중랑구 상봉역 치과 775  7
223 서울특별시 동대문구 청량리역 치과 774  3
224 서울특별시 성북구 성심여대역 일반병원 770  4
225 서울특별시 동대문구 회기역 한정식 767  4
226 서울특별시 동대문구 장한평1 자동차경정비 763  5
227 서울특별시 동대문구 장한평1 슈퍼마켓(일반) 756  6
228 서울특별시 금천구 독산사거리 인근 자동차경정비 751  9
229 서울특별시 성북구 성심여대역 일반의류 743  5
230 서울특별시 금천구 협진교차로 인근 자동차경정비 730  10
231 서울특별시 성북구 성심여대역 한정식 721  6
232 서울특별시 동대문구 회기역 약국 716  7
233 서울특별시 동대문구 회기역 분식 712  8
234 서울특별시 중랑구 중화구청사거리 일반의류 709  8
235 서울특별시 중랑구 면목역 슈퍼마켓(일반) 676  9
236 서울특별시 성북구 성심여대역 남성미용실 659  7
237 서울특별시 성북구 성심여대역 정통호프 655  8
238 서울특별시 중랑구 중화구청사거리 치과 653  10
239 서울특별시 성북구 성심여대역 분식 625  9
240 서울특별시 동대문구 장한평1 차량물품/인테리어 613  9
241 서울특별시 도봉구 미화예식장거리 조명/전기용품 613  4
242 서울특별시 동대문구 청량리역 일반병원 610  10
243 서울특별시 도봉구 창동역 약국 593  5
244 서울특별시 도봉구 쌍문역 치과 586  6
245 서울특별시 성북구 성심여대역 패밀리레스토랑 582  10
246 서울특별시 도봉구 미화예식장거리 치과 530  7
247 서울특별시 도봉구 창동역 한정식 528  8
248 서울특별시 도봉구 창동역 정통호프 487  9
249 서울특별시 도봉구 쌍문역 분식 474  10

A: The above information is nice and fascinating. It shows that 7 out of top 10 businesses are all in 'kangnam,' while the remaining two are in 'jongro' and the last one in 'seongdong.' Also, 6 out of top 10 businesses belong to 'medical' sector businesses. These are nice and detailed. To understand it in a broader sense, however, we need to conduct the same simple procedre we normally carry out--that is, statistics and visualization.

In [19]:
top_business = pd.read_csv('1_top_business.csv')
top_business.head()
Out[19]:
province city area_name business_type total rank
0 ����Ư���� ������ ������ �Ʒ� ��ǻ��/�ֺ���� 13598 1
1 ����Ư���� ������ �б����� �����ܰ� 11123 2
2 ����Ư���� ������ ������ �� �����ܰ� 9635 3
3 ����Ư���� ���α� ������ �α� ����/���� 6393 1
4 ����Ư���� ������ �Ż� ������ �����ܰ� 6140 4
In [20]:
top_business_revenue = top_business['total']
print 'Top business statistics'
print
print 'Mean: ' + str(int(top_business_revenue.mean()))
print 'Max: ' + str(top_business_revenue.max())
print 'Min: ' + str(top_business_revenue.min())
print 'Standard deviation: ' + str(int(top_business_revenue.std()))
print '65%: ' + str([0, 1530+1369])
print '95%: ' + str([0,1530+1369*2])
print '99%: ' + str([0,1530+1369*3])
print 'Total businesses: ' + str(len(top_business_revenue))
print
print 'Top 10 business revenue \n' + str(top_business_revenue[0:10])
Top business statistics

Mean: 1530
Max: 13598
Min: 474
Standard deviation: 1369
65%: [0, 2899]
95%: [0, 4268]
99%: [0, 5637]
Total businesses: 250

Top 10 business revenue 
0    13598
1    11123
2     9635
3     6393
4     6140
5     5280
6     4242
7     3931
8     3895
9     3631
Name: total, dtype: int64

A: One can see that if business makes more than 5,637, then it belongs to top 1%.

Let's see whether these business revenues are polarized

In [21]:
top_1_percent_revenue = 0
bottom_99_percent_revenue = 0

for i in range(0,5):
    top_1_percent_revenue = top_1_percent_revenue + top_business_revenue[i]
    
for j in range(6,250):
    bottom_99_percent_revenue = bottom_99_percent_revenue + top_business_revenue[j]
    
print 
print
print 'Revenue by top 1% (6 businesses):        ' + str(top_1_percent_revenue)
print 'Revenue by bottom 99% (244 businesses): ' + str(bottom_99_percent_revenue)

print
print
top_10_percent_revenue = 0
bottom_90_percent_revenue = 0

for i in range(0,25):
    top_10_percent_revenue = top_10_percent_revenue + top_business_revenue[i]
    
for j in range(26,250):
    bottom_90_percent_revenue = bottom_90_percent_revenue + top_business_revenue[j]
    
print 'Revenue by top 10%(25 businesses):      ' + str(top_10_percent_revenue)
print 'Revenue by bottom 90% (225 businesses): ' + str(bottom_90_percent_revenue)

print
print
top_28_percent_revenue = 0
bottom_72_percent_revenue = 0

for i in range(0,70):
    top_28_percent_revenue = top_28_percent_revenue + top_business_revenue[i]
    
for j in range(71,250):
    bottom_72_percent_revenue = bottom_72_percent_revenue + top_business_revenue[j]
    
print 'Revenue by top 28%(70 businesses):      ' + str(top_28_percent_revenue)
print 'Revenue by bottom 72% (180 businesses): ' + str(bottom_72_percent_revenue)

Revenue by top 1% (6 businesses):        46889
Revenue by bottom 99% (244 businesses): 330433


Revenue by top 10%(25 businesses):      109560
Revenue by bottom 90% (225 businesses): 270843


Revenue by top 28%(70 businesses):      190329
Revenue by bottom 72% (180 businesses): 190713

A: The above analysis shows that top 30% of all the businesses earn as much as 72% of the businesses.

Note: Can this data be used to argue that businesses are polarized?

In [22]:
plt.hist(top_business_revenue, bins=50)
plt.xlabel('Revenue (won)')
plt.ylabel('Frequency')

# plt.title(r'$\mathrm{Total\ Revenue\ Distribution:}\ \mu=14787,\ \sigma=1369$')

plt.title(r'$\mathrm{Top\ Business:}\ \mu=1530,\ \sigma=1369$')
plt.show()

A: 6 out of 250 businesses make more than 5,000--this makes these 6 businesses top 1%. The remaining 244 businesses make less than 5,000. This confirms again that economic polarization is serious.

Now that we have analyzed quite a bit about our dataset. Let's move on to formulating a hypothesis.

We approach this process by first enumerating some of the insights or information we have gathered so far, because these information will work collectively to provide us a topic. They are as follows.

  1. Economic polarization in districts (e.g. 'kangnam', 'seocho' vs rest, top 6 districts vs bottom 19 districts)
  2. Economic polarization in businesses ("can 30 % vs 70% be considered polarization?")
  3. Top two sectors that generate the most revenue are 'medical' and 'wholesale.'
  4. Two sectors that contribute the least in terms of revenue generated are 'education' and 'service.'
  5. 7 out of 10 top businesses are located in 'kangnam'
  6. 6 out of 10 top businesses belong to 'medical' sector
  7. Top 2 districts that garnered the most revenues consistently in every sector were 'kangnam' and 'seocho.'

  • Hypthesis Formulation
  1. Two districts, 'kangnam' and 'seocho', will always fair well even when other districts are not well-off.
  2. Since 'medical' and 'wholesale' are the top two sectors that contribute the most to the overall revenue, if they are not doing well, the overall revenue will be heavily influenced. And vice versa.

  3. Even in times of economic hardship, top sectors will generate revenue. On the other hand, bottom sectors, such as 'education' and 'service', will be heavily influenced. (Not tested)

III. Hypothesis Testing

In this section, we set out to explore and test whether the formulated hypothesis is true or not. For this, we will refer to data visualization system provided by geovision. (http://datablog.geovision.co.kr/index.php/analysis02/)

1. First Hypothesis

"Will the two districts, 'kangnam' and 'seocho', always fair well even when other districts are not well-off?"

To check whether these two districts do okay even in times of economic trouble, I chose the month, 'October', where decrease in overall revenue (from previous month) was the highest(-12.42%), as shown in below image. However, it must be noted that the decrease could have been higher than other months, because overall revenue in the previous month was high. Indeed, this was the case for 'October.' As a result, I check the month, 'February'(-4.59%) as well. (Note that I skip 'January,' because the information about 'December' of previous year is not available and thus, the same problem can apply)

First, let's look at 'October' (-12.42%)

A: 'Kangnam' decreased by 18.0%. 'Seocho' decreased by 15.1%. ('Seongdong' decreased by 3.9%. 'Mapo' decreased by 18.6%.)

A: This is contrary to our hypothesis, but we can still investigate further by asking, "did 'Kangnam' and 'Seocho' see such high decrease in revenue, because 'Kangnam' and 'Seocho' did very well in a previous month?"

Well, let's check 'September'! (+6.0%)

A: Indeed, though 'Seocho' only saw increase in revenue by 1.5%, the revenue of 'Kangnam' increased by 7.8%!

Now, let's take a look at 'February' (-4.59%)

A: 'Kangnam' increased by 1.9%. 'Seocho' decreased by 0.5%. ('Seongdong' increased by 3.1%. 'Kangseo' decreased by 15.1%.)

A: When overall revenue of 18 cities decreased, the overall revenue of 'Kangnam' rather increased by 1.9%. It was one of the 3 districts ('Seongdong','Eunpyeong','Kangnam') that actually increased in total revenue

Conclusion

In conclusion, although more convincing cases will definitely help to make the hypothesis valid, it can be said for now that the analysis seems to demonstrate that our hypothesis may not be too far-fetched.

2. Second Hypothesis

"Since 'medical' and 'wholesale' are the top two sectors that contribute the most to the overall revenue, if they are not doing well, the overall revenue will be heavily influenced. And vice versa."

To check this hypothesis, I first looked at the histogram of 'medical' sector. It presents a collection of percent increase in each month, as shown below. 'October' has -2.25%, and 'February' has -0.60%. However, in the month prior to 'October', there was 7.56% increase in revenue (September), while 'January' had 2.91% increase. Like we have done when we were testing the first hypothesis, this needs to be taken into account for normalization. For now, I will take a simpler approach and just test both 'February' and 'October.'

In the midst of an attempt to test this hypothesis, I discovered that simply looking at 'medical' sector alone would result in misleading analysis. This is because in the month of 'October,' all the other sectors saw decrease in revenue. This is illustrated in the below image.

For proper testing of this hypothesis, only 'medical' and 'wholesale' sectors have to see decrease in revenue, while all the other sectors have increase in revenue, not to mention additional comlexities involved. Since it does not have the combination needed, it was clear that examination of this hypothesis was no longer feasible.

Conclusion

This trial allowed me to experience the importance of the art of narrowing down: the reason for my failure with this experiment is a result of not carefully dissecting hypothesis formulation and in the process making it as detailed as possible.

VI. Conclusion

From this assignment, I realized how much effort and thoughts need to be exerted for proper analysis. Also, the importance of dataset was confirmed again. Overall, the assignment was a challenging yet rewarding experience.