설문조사 응답 분석 1
참고 URL :
캐글을 시작한 지 두 달 정도 된 초보자로, 이 설문조사의 결과를 바탕으로 데이터 사이언스와 머신러닝과 관련된 인사이트를 얻어볼 수 있지 않을까 가설을 세워본다.
캐글러를 대상으로 한 설문조사
- 설문 기간 : 2017년 8월 7일부터 8월 25일까지
- 평균 응답 시간은 16.4 분
- 171개 국가 및 지역에서 16,716명의 응답자
- 특정 국가 또는 지역에서 응답자가 50명 미만인 경우 익명을 위해 그룹을 '기타' 그룹으로 그룹화
- 설문 조사 시스템에 신고 된 응답자를 스팸으로 분류하거나 취업 상태에 관한 질문에 답변하지 않은 응답자는 제외(이 질문은 첫 번째 필수 질문이기에 응답하지 않으면 응답자가 다섯 번째 질문 이후 진행되지 않음)
- 대부분 응답자는 이메일 목록, 토론 포럼 및 소셜 미디어 Kaggle 채널을 통해 설문을 알게 됨
- 급여데이터는 일부 통화에 대해서만 받고 해당하는 통화에 기준으로 하여 작성하도록 함
- 미국 달러로 급여를 계산할 수 있도록 USD로 환산 한 csv를 제공
- 질문은 선택적
- 모든 질문이 모든 응답자에게 보이는 것은 아님
- 취업을 한 사람과 학생을 나누어 다른 질문을 함
- 응답자의 신원을 보호하기 위해 주관식과 객관식 파일로 분리
- 객관식과 자유 형식 응답을 맞추기 위한 키를 제공하지 않음
- 주관식 응답은 같은 행에 나타나는 응답이 반드시 동일한 설문 조사자가 제공하지 않도록 열 단위로 무작위 지정
데이터 파일
5개의 데이터 파일을 제공
- schema.csv : 설문 스키마가 있는 CSV 파일입니다. 이 스키마에는 multipleChoiceResponses.csv 및 freeformResponses.csv의 각 열 이름에 해당하는 질문이 포함되어 있습니다.
- multipleChoiceResponses.csv : 객관식 및 순위 질문에 대한 응답자의 답변, 각 행이 한 응답자의 응답
- freeformResponses.csv : Kaggle의 설문 조사 질문에 대한 응답자의 주관식 답변입니다. 임의로 지정되어 각 행이 같은 응답자를 나타내지 않음
- conversionRates.csv : R 패키지 "quantmod"에서 2017년 9월 14일에 액세스 한 통화 변환율 (USD)
- RespondentTypeREADME.txt : schema.csv 파일의 "Asked" 열에 응답을 디코딩하는 스키마입니다.
# 노트북 안에서 그래프를 그리기 위해
%matplotlib inline
# Import the standard Python Scientific Libraries
import pandas as pd
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
import seaborn as sns
# Suppress Deprecation and Incorrect Usage Warnings
import warnings
warnings.filterwarnings('ignore')
question = pd.read_csv('data/schema.csv')
question.shape
(290, 3)
question.tail()
Column | Question | Asked | |
---|---|---|---|
285 | JobFactorRemote | How are you assessing potential job opportunit... | Learners |
286 | JobFactorIndustry | How are you assessing potential job opportunit... | Learners |
287 | JobFactorLeaderReputation | How are you assessing potential job opportunit... | Learners |
288 | JobFactorDiversity | How are you assessing potential job opportunit... | Learners |
289 | JobFactorPublishingOpportunity | How are you assessing potential job opportunit... | Learners |
# 판다스로 선다형 객관식 문제에 대한 응답을 가져옴
mcq = pd.read_csv('data/multipleChoiceResponses.csv',
encoding="ISO-8859-1", low_memory=False)
mcq.shape
(16716, 228)
mcq.columns
Index(['GenderSelect', 'Country', 'Age', 'EmploymentStatus', 'StudentStatus',
'LearningDataScience', 'CodeWriter', 'CareerSwitcher',
'CurrentJobTitleSelect', 'TitleFit',
...
'JobFactorExperienceLevel', 'JobFactorDepartment', 'JobFactorTitle',
'JobFactorCompanyFunding', 'JobFactorImpact', 'JobFactorRemote',
'JobFactorIndustry', 'JobFactorLeaderReputation', 'JobFactorDiversity',
'JobFactorPublishingOpportunity'],
dtype='object', length=228)
mcq.head(10)
GenderSelect | Country | Age | EmploymentStatus | StudentStatus | LearningDataScience | CodeWriter | CareerSwitcher | CurrentJobTitleSelect | TitleFit | ... | JobFactorExperienceLevel | JobFactorDepartment | JobFactorTitle | JobFactorCompanyFunding | JobFactorImpact | JobFactorRemote | JobFactorIndustry | JobFactorLeaderReputation | JobFactorDiversity | JobFactorPublishingOpportunity | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | Non-binary, genderqueer, or gender non-conforming | NaN | NaN | Employed full-time | NaN | NaN | Yes | NaN | DBA/Database Engineer | Fine | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
1 | Female | United States | 30.0 | Not employed, but looking for work | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | Somewhat important | NaN | NaN |
2 | Male | Canada | 28.0 | Not employed, but looking for work | NaN | NaN | NaN | NaN | NaN | NaN | ... | Very Important | Very Important | Very Important | Very Important | Very Important | Very Important | Very Important | Very Important | Very Important | Very Important |
3 | Male | United States | 56.0 | Independent contractor, freelancer, or self-em... | NaN | NaN | Yes | NaN | Operations Research Practitioner | Poorly | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
4 | Male | Taiwan | 38.0 | Employed full-time | NaN | NaN | Yes | NaN | Computer Scientist | Fine | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
5 | Male | Brazil | 46.0 | Employed full-time | NaN | NaN | Yes | NaN | Data Scientist | Fine | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
6 | Male | United States | 35.0 | Employed full-time | NaN | NaN | Yes | NaN | Computer Scientist | Fine | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
7 | Female | India | 22.0 | Employed full-time | NaN | NaN | No | Yes | Software Developer/Software Engineer | Fine | ... | Very Important | Somewhat important | Very Important | Somewhat important | Somewhat important | Not important | Very Important | Very Important | Somewhat important | Somewhat important |
8 | Female | Australia | 43.0 | Employed full-time | NaN | NaN | Yes | NaN | Business Analyst | Fine | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
9 | Male | Russia | 33.0 | Employed full-time | NaN | NaN | Yes | NaN | Software Developer/Software Engineer | Fine | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
10 rows × 228 columns
# missingno는 NaN 데이터들에 대해 시각화를 해준다.
# NaN 데이터의 컬럼이 많아 아래 그래프만으로는 내용을 파악하기 어렵다.
import missingno as msno
msno.matrix(mcq, figsize=(12,5))
- 16,716명의 데이터와 228개의 선다형 객관식 문제와 62개의 주관식 질문에 대한 응답이다. (총 290개의 질문) 응답하지 않은 질문이 많음
설문통계
# 성별
sns.countplot(y='GenderSelect', data=mcq)
여성보다는 남성의 비율이 훨씬 높은 편이다.
# 국가별 응답 수
con_df = pd.DataFrame(mcq['Country'].value_counts())
# print(con_df)
# 'country' 컬럼을 인덱스로 지정해 주고
con_df['국가'] = con_df.index
# 컬럼의 순서대로 응답 수, 국가로 칼럼 명을 지정해 줌
con_df.columns = ['응답 수', '국가']
# index 컬럼을 삭제하고 순위를 알기 위해 reset_index()를 해준다.
# 우리나라는 18위이고 전체 52개국에서 참여했지만 20위까지만 본다.
con_df = con_df.reset_index().drop('index', axis=1)
con_df.head(20)
응답 수 | 국가 | |
---|---|---|
0 | 4197 | United States |
1 | 2704 | India |
2 | 1023 | Other |
3 | 578 | Russia |
4 | 535 | United Kingdom |
5 | 471 | People 's Republic of China |
6 | 465 | Brazil |
7 | 460 | Germany |
8 | 442 | France |
9 | 440 | Canada |
10 | 421 | Australia |
11 | 320 | Spain |
12 | 277 | Japan |
13 | 254 | Taiwan |
14 | 238 | Italy |
15 | 205 | Netherlands |
16 | 196 | Ukraine |
17 | 194 | South Korea |
18 | 184 | Poland |
19 | 184 | Singapore |
# 연령에 대한 정보를 본다.
mcq['Age'].describe()
count 16385.000000
mean 32.372841
std 10.473487
min 0.000000
25% 25.000000
50% 30.000000
75% 37.000000
max 100.000000
Name: Age, dtype: float64
sns.distplot(mcq[mcq['Age'] > 0]['Age'])
응답자의 대부분이 어리며,
20대부터 급격히 늘어나며, 30대가 가장 많다.
평균 나이는 32세다.
학력
sns.countplot(y='FormalEducation', data=mcq)
학사 학위를 가진 사람보다 석사 학위를 가지고 있는 사람이 많으며, 박사학위를 가지고 있는 사람들도 많다.
전공
# value_counts 를 사용하면 그룹화된 데이터의 카운트 값을 보여준다.
# normalize=True 옵션을 사용하면,
# 해당 데이터가 전체 데이터에서 어느 정도의 비율을 차지하는지 알 수 있다.
mcq_major_count = pd.DataFrame(
mcq['MajorSelect'].value_counts())
mcq_major_percent = pd.DataFrame(
mcq['MajorSelect'].value_counts(normalize=True))
mcq_major_df = mcq_major_count.merge(
mcq_major_percent, left_index=True, right_index=True)
mcq_major_df.columns = ['응답 수', '비율']
mcq_major_df
응답 수 | 비율 | |
---|---|---|
Computer Science | 4397 | 0.331074 |
Mathematics or statistics | 2220 | 0.167156 |
Engineering (non-computer focused) | 1339 | 0.100821 |
Electrical Engineering | 1303 | 0.098110 |
Other | 137 | 0.010315 |
I never declared a major | 65 | 0.004894 |
Fine arts or performing arts | 57 | 0.004292 |
컴퓨터 전공자들이 33%로 가장 많으며, 다음으로 수학, 공학, 전기 공학 순이다.
# 재학 중인 사람들의 전공 현황
plt.figure(figsize=(6,8))
sns.countplot(y='MajorSelect', data=mcq)
취업 여부
mcq_es_count = pd.DataFrame(
mcq['EmploymentStatus'].value_counts())
mcq_es_percent = pd.DataFrame(
mcq['EmploymentStatus'].value_counts(normalize=True))
mcq_es_df = mcq_es_count.merge(
mcq_es_percent, left_index=True, right_index=True)
mcq_es_df.columns = ['응답 수', '비율']
mcq_es_df
응답 수 | 비율 | |
---|---|---|
Employed full-time | 10897 | 0.651890 |
Not employed, but looking for work | 2110 | 0.126226 |
Independent contractor, freelancer, or self-employed | 1330 | 0.079564 |
Not employed, and not looking for work | 924 | 0.055276 |
Employed part-time | 917 | 0.054858 |
I prefer not to say | 420 | 0.025126 |
Retired | 118 | 0.007059 |
sns.countplot(y='EmploymentStatus', data=mcq)
응답자의 대부분이 65%가 풀타임으로 일하고 있으며, 그다음으로 구직자가 12%다.
프로그래밍 경험
- 'Tenure' 항목은 데이터 사이언스 분야에서 코딩 경험이 얼마나 되는지에 대한 질문이다. 대부분이 5년 미만이며, 특히 1~2년의 경험을 가진 사람들이 많다.
sns.countplot(y='Tenure', data=mcq)
korea = mcq.loc[(mcq['Country']=='South Korea')]
print('The number of interviewees in Korea: ' + str(korea.shape[0]))
sns.distplot(korea['Age'].dropna())
plt.title('Korean')
plt.show()
The number of interviewees in Korea: 194
pd.DataFrame(korea['GenderSelect'].value_counts())
GenderSelect | |
---|---|
Male | 156 |
Female | 37 |
A different identity | 1 |
sns.countplot(x='GenderSelect', data=korea)
plt.title('Korean')
Text(0.5,1,'Korean')
figure, (ax1, ax2) = plt.subplots(ncols=2)
figure.set_size_inches(12,5)
sns.distplot(korea['Age'].loc[korea['GenderSelect']=='Female'].dropna(),
norm_hist=False, color=sns.color_palette("Paired")[4], ax=ax1)
plt.title('korean Female')
sns.distplot(korea['Age'].loc[korea['GenderSelect']=='Male'].dropna(),
norm_hist=False, color=sns.color_palette("Paired")[0], ax=ax2)
plt.title('korean Male')
Text(0.5,1,'korean Male')
sns.barplot(x=korea['EmploymentStatus'].unique(), y=korea['EmploymentStatus'].value_counts()/len(korea))
plt.xticks(rotation=30, ha='right')
plt.title('Employment status of the korean')
plt.ylabel('')
plt.show()
korea['StudentStatus'] = korea['StudentStatus'].fillna('No')
sns.countplot(x='StudentStatus', data=korea)
plt.title('korean')
plt.show()
full_time = mcq.loc[(mcq['EmploymentStatus'] == 'Employed full-time')]
print(full_time.shape)
looking_for_job = mcq.loc[(
mcq['EmploymentStatus'] == 'Not employed, but looking for work')]
print(looking_for_job.shape)
(10897, 228)
(2110, 228)
-
subplot title 주는부분
-
2018.5.22 11:11
0
-
missingno 모듈 관련하여....
-
2018.4.24 21:52
2
-
데이터사이언스 입문 질문
김정민
2018.3.17 11:06
1