import pandas as pd
import numpy as np
import matplotlib. pyplot as plt
% matplotlib inline
df= pd. read_csv( 'DataAnalyst.csv' , encoding= 'gbk' )
df. head( )
city companyFullName companyId companyLabelList companyShortName companySize businessZones firstType secondType education industryField positionId positionAdvantage positionName positionLables bottom top avg workYear 0 上海 纽海信息技术(上海)有限公司 8581 ['技能培训', '节日礼物', '带薪年假', '岗位晋升'] 1号店 2000人以上 ['张江'] 技术 数据开发 硕士 移动互联网 2537336 知名平台 数据分析师 ['分析师', '数据分析', '数据挖掘', '数据'] 7 9 8.0 应届毕业生 1 上海 上海点荣金融信息服务有限责任公司 23177 ['节日礼物', '带薪年假', '岗位晋升', '扁平管理'] 点融网 500-2000人 ['五里桥', '打浦桥', '制造局路'] 技术 数据开发 本科 金融 2427485 挑战机会,团队好,与大牛合作,工作环境好 数据分析师-CR2017-SH2909 ['分析师', '数据分析', '数据挖掘', '数据'] 10 15 12.5 应届毕业生 2 上海 上海晶樵网络信息技术有限公司 57561 ['技能培训', '绩效奖金', '岗位晋升', '管理规范'] SPD 50-150人 ['打浦桥'] 设计 数据分析 本科 移动互联网 2511252 时间自由,领导nic 数据分析师 ['分析师', '数据分析', '数据'] 4 6 5.0 应届毕业生 3 上海 杭州数云信息技术有限公司上海分公司 7502 ['绩效奖金', '股票期权', '五险一金', '通讯津贴'] 数云 150-500人 ['龙华', '上海体育场', '万体馆'] 市场与销售 数据分析 本科 企业服务,数据服务 2427530 五险一金 绩效奖金 带薪年假 节日福利 大数据业务分析师【数云校招】 ['商业', '分析师', '大数据', '数据'] 6 8 7.0 应届毕业生 4 上海 上海银基富力信息技术有限公司 130876 ['年底双薪', '通讯津贴', '定期体检', '绩效奖金'] 银基富力 15-50人 ['上海影城', '新华路', '虹桥'] 技术 软件开发 本科 其他 2245819 在大牛下指导 BI开发/数据分析师 ['分析师', '数据分析', '数据', 'BI'] 2 3 2.5 应届毕业生
一、问题解决
plt. rcParams[ 'font.sans-serif' ] = [ 'SimHei' ]
plt. rcParams[ 'axes.unicode_minus' ] = False
plt. pie( df. groupby( 'education' ) . top. count( ) , labels= df. groupby( 'education' ) . top. count( ) . index)
([<matplotlib.patches.Wedge at 0x23703a1b1d0>,
<matplotlib.patches.Wedge at 0x23703a1b6a0>,
<matplotlib.patches.Wedge at 0x23703a1bbe0>,
<matplotlib.patches.Wedge at 0x23703a23160>,
<matplotlib.patches.Wedge at 0x23703a236a0>],
[Text(1.08382,0.187992,'不限'),
Text(1.03437,0.374265,'博士'),
Text(0.835846,0.715095,'大专'),
Text(-1.03506,-0.372359,'本科'),
Text(1.08084,-0.204438,'硕士')])
plt. plot( np. random. randint( - 20 , 20 , 20 ) )
[<matplotlib.lines.Line2D at 0x21ccd1f02e8>]
二、元素解析
基本参数
plt. figure( 1 , figsize= ( 10 , 4 ) )
plt. plot( np. random. randint( - 20 , 20 , 20 ) )
plt. title( 'cccc' )
plt. title( '这是一条折线' )
plt. xticks( [ 0 , 10 , 30 ] )
plt. xlabel( '我是x轴' )
plt. show( )
figure title data x轴 刻度xticks 标签xlabel y轴
多图的层叠
plt. plot( np. random. randint( - 20 , 20 , 20 ) )
plt. plot( np. random. randint( - 20 , 20 , 20 ) )
plt. legend( ( 'no1' , 'no2' ) )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no1' , color= 'g' )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no2' )
plt. legend( )
<matplotlib.legend.Legend at 0x21cce3c5f98>
data= df. groupby( [ 'education' , 'city' ] ) . agg( [ 'mean' , 'count' ] ) . avg. reset_index( )
data. head( )
education city mean count 0 不限 上海 14.051471 68 1 不限 北京 15.495238 210 2 不限 南京 7.000000 5 3 不限 厦门 12.500000 3 4 不限 天津 3.500000 1
for a, b in data. groupby( 'education' ) :
x= b[ 'mean' ]
y= b[ 'count' ]
plt. scatter( x, y, label= a)
plt. legend( loc= 'upper left' )
plt. xlabel( '平均薪资' )
plt. ylabel( '职位总数' )
plt. show( )
绘制子图
plt. figure( figsize= ( 12 , 4 ) )
plt. subplot( 1 , 2 , 1 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no1' , color= 'g' )
plt. legend( )
plt. subplot( 122 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no2' , color= 'r' )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no3' , color= 'b' )
plt. legend( )
plt. show( )
plt. figure( figsize= ( 12 , 4 ) )
plt. subplot( 2 , 1 , 1 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no1' , color= 'g' )
plt. legend( )
plt. subplot( 212 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no2' , color= 'r' )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no3' , color= 'b' )
plt. legend( )
plt. show( )
plt. figure( figsize= ( 12 , 8 ) )
plt. subplot( 2 , 2 , 1 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no1' , color= 'g' )
plt. subplot( 222 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no2' , color= 'r' )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no3' , color= 'b' )
plt. legend( )
plt. subplot( 2 , 2 , 3 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no4' , color= 'y' )
plt. subplot( 2 , 2 , 4 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no5' , color= 'black' )
plt. show( )
plt. figure( figsize= ( 12 , 8 ) )
plt. subplot( 2 , 2 , 1 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no1' , color= 'g' )
plt. legend( )
plt. subplot( 222 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no2' , color= 'r' )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no3' , color= 'b' )
plt. legend( )
plt. subplot( 212 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no4' , color= 'y' )
plt. show( )
plt. figure( figsize= ( 12 , 8 ) )
plt. subplot( 2 , 2 , 1 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no1' , color= 'g' )
plt. subplot( 223 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no2' , color= 'r' )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no3' , color= 'b' )
plt. legend( )
plt. subplot( 122 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no4' , color= 'y' )
plt. show( )
plt. figure( figsize= ( 12 , 4 ) )
plt. subplot( 121 )
plt. plot( np. random. randint( - 20 , 20 , 20 ) , label= 'no1' , color= 'g' )
for a, b in data. groupby( 'education' ) :
x= b[ 'mean' ]
y= b[ 'count' ]
plt. subplot( 122 )
plt. scatter( x, y, label= a)
plt. legend( loc= 'upper left' )
plt. xlabel( '平均薪资' )
plt. ylabel( '职位总数' )
plt. show( )