Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 错误“numpy.int32”对象不支持项分配_Python_Numpy - Fatal编程技术网

Python 错误“numpy.int32”对象不支持项分配

Python 错误“numpy.int32”对象不支持项分配,python,numpy,Python,Numpy,我得到这个错误 Traceback (most recent call last): File "C:\Users\User1\Desktop\cellh5_scripts\ewa_pnas_fate.py", line 90, in <module> ec.combine_classifiers("Event labels combined") File "C:\Users\User1\Desktop\cellh5_scripts\ewa_pnas_fate.py", li

我得到这个错误

Traceback (most recent call last):
File "C:\Users\User1\Desktop\cellh5_scripts\ewa_pnas_fate.py", line 90,     in <module>
ec.combine_classifiers("Event labels combined")
File "C:\Users\User1\Desktop\cellh5_scripts\ewa_pnas_fate.py", line 53, in combine_classifiers
pnas_class[pnas_class==3] = 1
TypeError: 'numpy.int32' object does not support item assignment
我打印的pnas_类为1,跟踪id为50708。我想知道代码设计者在这个部分想做什么:

inter_idx = h2b_class == 1 
pnas_class[pnas_class==3] = 1
pnas_class[pnas_class==2]+=2
combined_class = h2b_class
combined_class[inter_idx] = pnas_class[inter_idx] 
我如何才能将其更改为具有相同的含义?

pnas\u类是一个整数,因此您不能通过[pnas\u class==3]=1从整数中选择项

如果1等于3,可能你想影响1到pnas_类。在这种情况下,请尝试以下方法:

pnas_类=1*pnas_类==3+pnas_类*pnas_类!=3.
好的,我发现了错误。你是对的,pnas_类不应该是整数,我知道为什么它是整数而不是数组

inter_idx = h2b_class == 1 
pnas_class[pnas_class==3] = 1
pnas_class[pnas_class==2]+=2
combined_class = h2b_class
combined_class[inter_idx] = pnas_class[inter_idx]