4.数据可视化:Visualing earnings based

作者: 来个芒果 | 来源:发表于2017-04-19 17:41 被阅读0次

The dataset is stored in recent-grads.csv file.It contains information on earnings of college majors in US from 2010 to 2012.

It can be download form here:https://github.com/fivethirtyeight/data/tree/master/college-majors

In this project,I will explore the dataset and try to find some patterns in the earning of majors then plot it use matplotlib library.

代码使用jupyter完成:
读取数据:

import pandas as pd

recent_grads=pd.read_csv('./data/recent-grads.csv')
recent_grads.columns
print(recent_grads.info())
print(recent_grads.describe())
print(recent_grads.head(1))

处理缺失值:

raw_data_count=recent_grads.shape[0]
print(raw_data_count)
cleaned_data_count=recent_grads.dropna().shape[0]
print(cleaned_data_count)

==>>173
172
绘制散点图,查看各属性之间的关系:

import matplotlib.pyplot as plt
%matplotlib inline

recent_grads.plot(x='Full_time',y='Median',kind='scatter')
recent_grads.plot(x='Unemployed',y='Median',kind='scatter')
recent_grads.plot(x='Men',y='Median',kind='scatter')
recent_grads.plot(x='Women',y='Median',kind='scatter')

得到


我们继续绘制柱状图,查看各属性的分布情况:

columns=['Median','Employed','Employed','Unemployment_rate','Women','Men']
['Men'].hist()
fig=plt.figure(figsize=(6,18))
for i,col in enumerate(columns):
    ax=fig.add_subplot(6,1,i+1)
    ax=recent_grads[col].hist(color='orange')
plt.show()

为了更方便的查看就业人数与薪资的关系,使用scatter_matrix函数来构建散点图矩阵:

from pandas.tools.plotting import scatter_matrix
scatter_matrix(recent_grads[['Employed','Median']],figsize=(10,10),c=['red','blue'])

关于该矩阵的说明:

接下来不妨做些有意思的事情,分析一下薪资前10以及后10的专业中女生所占比例:

recent_grads[:10].plot.bar(x='Major',y='ShareWomen')
plt.legend(loc='upper left')
plt.title('The 10 highest paying majors.')
recent_grads[162:].plot(x='Major',y='ShareWomen',kind='bar')
plt.title('The 10 lowest paying majors.')

分析薪资较高的专业中的男女性别比例:

recent_grads[:10].plot.bar(x='Major',y=['Men','Women'])

相关文章

  • 4.数据可视化:Visualing earnings based

    The dataset is stored in recent-grads.csv file.It contain...

  • 数据挖掘过程常用函数总结

    1. 数据处理 2. 数据可视化 3.特征工程 4. 创建模型 5. 其他

  • 学习小组Day7笔记--韩峰

    1.学习测序知识 2.学习软件安装3.学习数据导入4.学习数据可视化结果分析

  • 4.数据可视化(一)

    数据可视化 4.1 简介 “The simple graph has brought more informati...

  • 4.数据可视化(二)

    4.6 几何对象 先来看看下面这两个图有什么相似之处呢? 两个图都包含相同的 x 变量和 y 变量,并且都描述了相...

  • 泰坦尼克-kaggle

    1.导入数据 2.可视化数据 3.清洗、转换数据 4.对数据编码 5.拆分训练集和测试集 6.进行学习 7.验证 ...

  • 离屏渲染[转]

    一、概述 OpenGL ES是一套多功能开放标准的用于嵌入系统的C-based的图形库,用于2D和3D数据的可视化...

  • OpenGL ES3(第一篇)

    OpenGL ES是一套多功能开放标准的用于嵌入系统的C-based的图形库,用于2D和3D数据的可视化。Open...

  • 离屏渲染

    一、概述 OpenGL ES是一套多功能开放标准的用于嵌入系统的C-based的图形库,用于2D和3D数据的可视化...

  • iOS学习日记-离屏渲染

    一、概述 OpenGL ES是一套多功能开放标准的用于嵌入系统的C-based的图形库,用于2D和3D数据的可视化...

网友评论

    本文标题:4.数据可视化:Visualing earnings based

    本文链接:https://www.haomeiwen.com/subject/fojhzttx.html