In [ ]:
import pandas as pd #reads the csv data
import matplotlib.pyplot as plt #data visualization
import seaborn as sns #more data visualization
In [ ]:
#read data
df = pd.read_csv('student.csv')
df.head(3) #deafult is 5, we put in 10 to see top 10 rows if data.. df.tail() to see last rows of data
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
In [ ]:
#counts the number of rows, not including the header
len(df)
Out[ ]:
1000
In [ ]:
#create a subset from df
sample_df= df.iloc[0:200, :] # 200 rows, and all columns
len(sample_df)
Out[ ]:
200
In [ ]:
#distribution between gender
sns.countplot(data= df, x= 'gender', hue= 'gender')
plt.show()
No description has been provided for this image
In [ ]:
#another way to do the samd thing
sns.catplot(data=df, x='gender', kind= 'count', hue='gender')
plt.show()
No description has been provided for this image
In [ ]:
#investigate how math score is distributed across gender
sns.catplot(data= df, x='gender', y='math_score', kind= 'bar', hue= 'lunch',
            palette={'standard':'green', 'free/reduced': 'lightgreen'}) #palette changes the colors you want to use
plt.show()
No description has been provided for this image
In [ ]:
#python easteregg
sns.dogplot()
No description has been provided for this image
In [ ]: