所以,我想这样做,如果输入x包含Averagefirearmsper100,那么应该给出以下输出
def correlation(x):
if x.str.contains("Averagefirearmsper100"):
print(corr1)
corr1plot.show()
if corr1 > -0.99 & corr1 < -0.4 :
print("strong negative relation")
elif corr1 > -0.39 & corr1 < -0.20 :
print('weak negative relation')
elif corr1 > -0.19 & corr1 < 0.19 :
print('no or negligible relation')
elif corr1 > 0.20 & corr1 <0.39 :
print('weak positive relation')
elif corr1 > 0.4 & corr1 < 0.99 :
print('strong positive relation')
AttributeError
Traceback (most recent call last)
<ipython-input-57-dc3f5f5c9df1> in <module>()
----> 1 correlation("HDI")
<ipython-input-56-308ea6ff6259> in correlation(x)
1 def correlation(x):
----> 2 if x.str.contains("Averagefirearmsper100"):
3 print(corr1)
4 corr1plot.show()
5 if corr1 > -0.99 & corr1 < -0.4 :
AttributeError: 'str' object has no attribute 'str'
如果输入
x
的类型为str
,则会发生错误,因为str
没有名为str
的属性您可以尝试从更改代码
到
相关问题 更多 >
编程相关推荐