准备工作
下载数据集
下载地址:Students Performance in Exams
下载时需要登录,选择最后一项skp&continue download即可.
查看数据结构
字段 | 描述 |
---|---|
gender | 性别 |
race/ethnicity | 种族 |
parental level of education | 父母教育水平 |
lunch | 午餐 |
test preparation course | |
math score | 数学 |
reading score | 阅读 |
writting score | 写作 |
数据分析
查看数据
查看各列信息,可以看到总共有1000行,每行八列数据
data.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1000 entries, 0 to 999
Data columns (total 8 columns):
gender 1000 non-null object
race/ethnicity 1000 non-null object
parental level of education 1000 non-null object
lunch 1000 non-null object
test preparation course 1000 non-null object
math score 1000 non-null int64
reading score 1000 non-null int64
writing score 1000 non-null int64
dtypes: int64(3), object(5)
memory usage: 62.6+ KB
data.describe()
数字列的最大最小值,平均值等
data.isnull().sum()
空值统计
分析数据
柱状图
显示不同种族学生的人数
plt.figure(figsize=(20, 10))
sns.countplot(data=data, x='race/ethnicity')
绘制饼图
根据种族数量绘制饼状图
data['race/ethnicity'].value_counts().plot.pie()