# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3.7.4 64-bit
#     language: python
#     name: python37464bit297b18a1a3e542689b13a325bcf6fffe
# ---

# #### Part 1 | Load and Validate the Data
# #### Part 2 | Merge Dataframes
# #### Part 3 | Data Exploration
# #### Part 4 | Visualizations

# ## Part 1 | Load and Validate the Data

# +
# imports

import pandas as pd
import os
import matplotlib.pyplot as plt
import seaborn as sns 
# -

math_path = '/home/chase/repos/Student_Performance/data/student-mat.csv'
math = pd.read_csv(math_path, sep=';')
port_path = '/home/chase/repos/Student_Performance/data/student-por.csv'
port = pd.read_csv(port_path, sep=';')

print(math.shape)
print(math.head())
print(port.shape)
print(port.head())

# ## Part 2 | Merge Dataframes

# +
# merge datasets

df = pd.concat([math, port])

# rename columns

df.columns = ['school','sex','age','address','family_size','parents_status','mother_education','father_education',
              'mother_job','father_job','reason','guardian','commute_time','study_time','failures','school_support',
              'family_support','paid_classes','activities','nursery','desire_higher_edu','internet','romantic','family_quality',
              'free_time','go_out','weekday_alcohol_use','weekend_alcohol_use','health','absences','period1_score','period2_score',
              'final_score']

df.head()

# +
# convert and assign final score to pass(1) & fail(0)
# pass >= 14
# fail < 14

df['passing_grade'] = 'passing_grade'
df.loc[(df.final_score >= 14), 'passing_grade'] = 1
df.loc[(df.final_score < 14), 'passing_grade'] = 0
df.head()

# +
# check for nan's

df.isnull().sum()
# -

# ## Part 3 | Data Exploration

print(df.shape)
print(df.dtypes)

# +
# convert passing grades to ints

df['passing_grade'] = df.passing_grade.astype(int)
df.dtypes

# +
# save df as csv for later use

df.to_csv('/home/chase/repos/Student_Performance/data/student_performance.csv')
# -

df.describe()

# +
# baseline for later

df['passing_grade'].value_counts(normalize=True).max()
# -

# ## Part 4 | Visualizations

# +
# distribution plot of final_grade

sns.distplot(df['final_score']);

# +
# distribution plot of passing_grade

sns.distplot(df['passing_grade']);

# +
# passing_grade correlation heat map

corr = df.corr()
plt.figure(figsize=(15,15))
sns.heatmap(corr, annot=True, cmap="Blues")
plt.title('Correlation Heatmap', fontsize=15);

StarcoderdataJupyterScriptsDedupFiltered