본문 바로가기

Data Analysis/Kaggle

[Kaggle] Students Performance in Exam 데이터 분석 1 (데이터 확인 / 질문 / 전처리)

728x90

Students Performance in Exam 데이터셋 분석

분석 목적 : 학생 정보와 시험 점수와의 관계 분석

데이터 출처 : https://www.kaggle.com/spscientist/students-performance-in-exams

 

Students Performance in Exams

Marks secured by the students in various subjects

www.kaggle.com


1. 데이터 확인

# 기본 패키지 불러오기

import math
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use("seaborn") 
sns.set(font_scale = 1)
sns.set_style("whitegrid")

import plotly.express as px

import chart_studio.plotly as py
import cufflinks as cf
cf.go_offline(connected=True)

import plotly.graph_objects as go
import plotly.offline as pyo
pyo.init_notebook_mode()

from plotly.subplots import make_subplots

import missingno as msno

import warnings # 경고 메세지 숨기기
warnings.filterwarnings(action='ignore')

plt.rcParams['font.family'] = 'S-Core Dream' # 한글 폰트 가져오기 (WIN)
# plt.rc("font", family = "AppleGothic") # 한글 폰트 가져오기 (MAC)
plt.rcParams['axes.unicode_minus'] = False # - 기호 깨짐 해결

 

# 데이터 불러오기

student = pd.read_csv("data/StudentsPerformance.csv")

print(student.shape)
student.head()

<컬럼 설명>
- gender : 성별(남/녀)
- race/ethnicity : 인종/민족
- parental level of education : 부모 학력 수준
- lunch : 점심식사 여부
- test preparation course : 시험 준비학습 여부
- math score : 수학 성적
- reading score : 읽기 성적
- writing scre : 쓰기 성적

 

 

# 데이터 정보 확인

student.info()

 

 

# 수치형 데이터 통계 확인

student.describe()

 

 

# 범주형 데이터 통계 확인

student.describe(include = np.object_)

 

 

# 결측치 확인

student.isnull().sum()

결측치는 없습니다.

 

 

# 데이터 내용 간략히 정리

print("전체 데이터 수:",student.shape[0] * student.shape[1])
print("결측치 수:",student.isnull().sum().sum())
print("전체 학생 수:", student["gender"].count())


2. 질문하기

1) 성별과 성적의 관계는?  
2) 인종/민족과 성적의 관계는?  
3) 부모 교육 수준과 성적의 관계는?  
4) 점심식사 여부와 성적의 관계는?  
5) 시험 준비학습 여부와 성적의 관계는?  
6) 각 시험 성적의 상관관계는?  


3. 데이터 전처리

# 원본 데이터를 copy 하여 신규 데이터프레임 생성

sp = student.copy()

print(sp.shape)
sp.head()
728x90