我正在分析FreeCodeCamp 1拍摄的2016年调查数据。 https://github.com/freeCodeCamp/2016-new-coder-survey
特别是2016年新编码器调查/清洁数据/ 2016-FCC-New-Coders-Survey-Data.csv
由于某种原因,我想要添加的任何其他图都不会显示。给出错误
raise AttributeError('Unknown property %s' % k)
AttributeError: Unknown property type
我的代码如下:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data_file = pd.read_csv('FCC_New_Coders_Survey_Data.csv', dtype={'AttendedBootcamp': float, 'CodeEventOther': object, 'JobRoleInterestOther': object})
AttendedBootcamp = data_file['AttendedBootcamp']
BootcampFullJobAfter = data_file['BootcampFullJobAfter']
BootcampRecommend = data_file['BootcampRecommend']
BootcampFinish = data_file['BootcampFinish']
Age = data_file['Age']
NetworkID = data_file['NetworkID']
AttendYes = data_file[data_file.AttendedBootcamp == 1]
AgeAttend = AttendYes['Age']
FinishYes = data_file[data_file.BootcampFinish == 1]
FinishNo = data_file[data_file.BootcampFinish == 0]
JobYes = data_file[data_file.BootcampFullJobAfter == 1]
JobNo = data_file[data_file.BootcampFullJobAfter == 0]
RecYes = data_file[data_file.BootcampRecommend == 1]
RecNo = data_file[data_file.BootcampRecommend == 0]
var = [len(JobYes[JobYes.Age == i]) - len(JobNo[JobNo.Age == i]) for i in range(16, 60)]
x = range(16, 60)
y = var
fig = plt.figure(figsize=(8,8))
plt.plot(x, y, 'go')
plt.xlabel('Age')
plt.ylabel('Net Employment Difference (count)')
plt.title('Employement Discrepencies')
plt.xticks(x)
plt.xscale('linear')
ax = fig.add_subplot(1, 1, 1)
ax.spines['bottom'].set_position('zero')
plt.vlines(x, [0], y)
ax.xaxis.set_ticks(np.arange(15, 65, 5))
plt.xlabel('Age', horizontalalignment='center', verticalalignment='center', x=1.05)
plt.show()
plt.figure(figsize=(8,8))
plt.title('bootcamp job')
plt.hist([JobYes['Age'], JobNo['Age']], histtype='bar', bins = 44, range=[16,60], label=['Job after camp', 'no job after camp'])
plt.xlabel('Age')
plt.ylabel('Count')
plt.legend()
plt.figure(figsize=(8,8))
plt.title('Attend bootcamp')
plt.hist(AttendYes['Age'], histtype='bar', range=[16,60])
plt.xlabel('Age')
plt.ylabel('Count')
plt.legend()
plt.figure(figsize=(8,8))
plt.title('bootcampfinish')
plt.hist([FinishYes['Age'], FinishNo['Age']], type='bar', range=[16,60], label=['finished', 'didn\'t finish'])
plt.xlabel('Age')
plt.ylabel('Count')
plt.legend()
var1 = [len(RecYes[RecYes.Age == j]) - len(RecNo[RecNo.Age == j]) for j in range(16, 60)]
x1 = range(16, 60)
y1 = var1
plt.figure(figsize=(8,8))
plt.plot(x1, y1)
plt.xlabel('Age')
plt.ylabel('Net reccomendation (count)')
plt.title('Age Sentiment')
plt.xticks(x1)
plt.xscale('linear')
plt.legend()
plt.show()
如果我要评论说,前四个情节中的一个,那么第五个情节就会显示出来。
答案 0 :(得分:0)
你的问题不在于情节的数量,而在第五个情节的调用中有一个拼写错误。据我所知,绘图的数量没有限制(除了你自己的计算机内存,我猜)
在您的第五个图中,您在plt.hist(..., type='bar')
时应该像前四个图中一样调用plt.hist(..., histtype='bar')
。