我正在尝试绘制箱线图,但遇到了“非类型属性错误”
拜托,我该怎么修?你知道吗
我的代码:
Failed = train_df['Fees'][train_df['Passedornot'] == 0]
Passed = train_df['Fees'][train_df['Passedornot'] ==1]
average_fees = DataFrame([mean(Passed), mean(Failed)])
std_fees = DataFrame([standard_deviation(Passed), standard_deviation(Failed)])
fig, axis4 = plt.subplots(1,1)
train_df['Fees'].plot(kind='hist', figsize=(15,5),bins=100, xlim=(0,30), ax=axis4)
fig, axis5 = plt.subplots(1,1)
average_fees.plot(kind='', legend=False, ax=axis5)
错误:
average_fees.plot(kind='bp', legend=False, ax=axis5)
AttributeError: 'NoneType' object has no attribute 'plot'
数据样本:
Name Sex Age Score Passedornot Fees
Tim Cole male 18 148 1 90
Ellen James female 47 143 1 80
Jerome Miles male 62 144 0 80
Waltz Albert male 27 153 0 90
不知道那里发生了什么,但我认为你的
average_fees
不是一个合适的数据帧。此外,我的编译器还在抱怨kind='bp'
。这就是为什么社区总是要求提供一个功能齐全的工作示例的原因之一。你知道吗这里是Python3的一个工作片段,运行在Jupyter笔记本中,用于保存到文件中的您提供的数据片段示例.txt地址:
相关问题 更多 >
编程相关推荐