简体   繁体   English

如何解决TypeError:无法将序列乘以'float'类型的非整数

[英]How to solve TypeError: can't multiply sequence by non-int of type 'float'

my question seems what many people already frequently asked. 我的问题似乎很多人已经问过。

I might missed something, but most solution suggested in related thread doesn't seem to work. 我可能错过了一些东西,但是相关线程中建议的大多数解决方案似乎都不起作用。

My purpose is simply multiplying series of numbers and lists which I used to do. 我的目的是简单地乘以我以前做过的一系列数字和列表。

I haven't seen such a type error before. 我以前没有见过这样的类型错误。

Following are my code: 以下是我的代码:

while c1 < 95:
    c1 = c1 + 1
    a1 = []

    f1.seek(0,0)
    arrays1 = [map(float, line.split()) for line in f1]
    newa1 = [x[5:] for x in arrays1]


    a1 = newa1[c1]
    x1 = np.array(a1, float)
    x1 = np.ma.masked_array(x1,np.isnan(x1))

    xa1 = [i for i in x1 if i>=3.5 or i<=13.]

    print xa1

    p1 = 0.95*0.90*0.5*0.4*1.03*5027.*xa1^3

Because my data has many nan value, I used masked array for this code. 因为我的数据有很多nan值,所以我在代码中使用了masked array。 However the result error were same whether I used original data, masked array or just ignore nan values. 但是无论我使用原始数据,掩码数组还是忽略nan值,结果错误都是相同的。

If any of you have any idea, I really appreciate. 如果您有任何想法,我真的很感激。

Thank you, 谢谢,

Isaac 艾萨克

p1 = xa1**3 * 0.95*0.90*0.5*0.4*1.03*5027.

你需要先拥有你的数组(也许...(实际上我不认为这是真的))也如上所述**是你如何在python中进行运算

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 typeerror:不能将序列乘以“int”类型的非int - typeerror: can't multiply sequence by non-int of type "float TypeError:无法将序列乘以float类型的非整数 - TypeError:can't multiply sequence by non-int of type float TypeError:不能将序列乘以“float”类型的非整数? - TypeError: can't multiply sequence by non-int of type 'float'? 类型错误:不能将序列乘以浮点类型的非整数 - TypeError: Can't multiply sequence by non-int of type float TypeError:无法将序列乘以&#39;float&#39;类型的非整数 - TypeError: can't multiply sequence by non-int of type 'float' 我如何解决:不能将序列乘以“float”类型的非整数(python) - how i can solve : can't multiply sequence by non-int of type 'float' (python) 如何解决python中的“无法将序列乘以&#39;float&#39;类型的非整数”的问题 - How do I solve the issue “can't multiply sequence by non-int of type 'float'” in python 如何删除“ TypeError:无法将序列乘以&#39;float&#39;类型的非整数”? - how to remove “TypeError: can't multiply sequence by non-int of type 'float' ”? 如何解决 - TypeError:不能将序列乘以“float”类型的非整数 - How to resolve - TypeError: can't multiply sequence by non-int of type 'float' 如何修复 TypeError:不能将序列乘以“numpy.float64”类型的非整数 - How to fix TypeError: can't multiply sequence by non-int of type 'numpy.float64'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM