In [ ]:
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
In [ ]:
df = pd.read_csv('student.csv')
df.head()
Out[ ]:
| gender | ethnicity | parental_education | lunch | test_preparation_course | math_score | reading_score | writing_score | |
|---|---|---|---|---|---|---|---|---|
| 0 | female | group B | bachelor's degree | standard | none | 72 | 72 | 74 |
| 1 | female | group C | some college | standard | completed | 69 | 90 | 88 |
| 2 | female | group B | master's degree | standard | none | 90 | 95 | 93 |
| 3 | male | group A | associate's degree | free/reduced | none | 47 | 57 | 44 |
| 4 | male | group C | some college | standard | none | 76 | 78 | 75 |
In [ ]:
#create our first histogram
#explore how math score is distributed over entire students
plt.figure(figsize=(4,3))
sns.histplot(data= df, x= 'math_score', kde=True, color= '#d62828',
binwidth= 10, fill= False)# fill= flase takes away the inside color of the bars
plt.show()
In [ ]:
#countplot is to count 1 category
#catplot is to compare 2 categories
In [ ]:
#As a data scientist, if you want to determine which
#parental_education group has the highest average
#reading score, which visualization would you use
In [ ]:
plt.figure(figsize=(5,4))
sns.catplot(data= df, x= 'parental_education', y= 'reading_score', kind= 'bar',
hue= 'parental_education')
plt.xticks(rotation=20)
plt.show()
<Figure size 500x400 with 0 Axes>
In [ ]:
#If you want to determine which parental_education group
#has the largest number of students, which visualization
#would you use
In [ ]:
plt.figure(figsize=(5,4))
sns.countplot(data= df, x= 'parental_education', hue='parental_education')
plt.xticks(rotation=20)
plt.show()
In [ ]:
#If you want to explore how reading score spread, which
#visualization would you use?
In [ ]:
In [ ]:
#create our first histogram
#explore how math score is distributed over entire students
plt.figure(figsize=(4,3))
sns.histplot(data= df, x= 'reading_score', kde=True, color= '#d62828',
binwidth= 5)
plt.show()
In [ ]: