Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.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 索引器错误:索引43770超出大小为37550的轴0的界限_Python_Numpy - Fatal编程技术网

Python 索引器错误:索引43770超出大小为37550的轴0的界限

Python 索引器错误:索引43770超出大小为37550的轴0的界限,python,numpy,Python,Numpy,当我跑步时: im = np.zeros((37550, 59759)) location = [(23913, 43770), (23914, 43731), (23914, 43734), (23916, 43734), (23916, 43740), (23917, 43740), (23917, 43742), (23918, 43743), (23918, 43745), (23919, 43746), (23919, 43748

当我跑步时:

im = np.zeros((37550, 59759))  

location = [(23913, 43770), (23914, 43731), (23914, 43734), (23916, 43734), 
            (23916, 43740), (23917, 43740), (23917, 43742), (23918, 43743),
            (23918, 43745), (23919, 43746), (23919, 43748), (23920, 43750), 
            (23920, 43763), (23919, 43764), (23919, 43765), (23918, 43766), 
            (23918, 43768), (23917, 43769), (23917, 43770), (23916, 43771), 
            (23916, 43773), (23914, 43775), (23913, 43779), (23910, 43782), 
            (23909, 43784), (23909, 43786), (23906, 43792), (23906, 43795), 
            (23903, 43796), (23902, 43799), (23899, 43802), (23898, 43804), 
            (23897, 43805), (23896, 43808), (23892, 43810), (23891, 43813), 
            (23889, 43814), (23874, 43814), (23874, 43812), (23873, 43811), 
            (23873, 43809), (23872, 43808), (23870, 43802), (23869, 43801), 
            (23867, 43796), (23864, 43791), (23864, 43789), (23862, 43784), 
            (23861, 43783), (23860, 43781), (23857, 43780), (23856, 43779), 
            (23838, 43779), (23837, 43780), (23834, 43780), (23832, 43781), 
            (23830, 43783), (23828, 43783), (23827, 43785), (23823, 43789), 
            (23821, 43790), (23820, 43790), (23816, 43794), (23812, 43796), 
            (23810, 43798), (23806, 43800), (23802, 43801), (23797, 43801), 
            (23797, 43800), (23796, 43800), (23796, 43799), (23793, 43798), 
            (23793, 43796), (23791, 43794), (23791, 43764), (23792, 43762), 
            (23792, 43759), (23793, 43758), (23793, 43756), (23794, 43754),  
            (23794, 43753), (23796, 43752), (23797, 43751), (23800, 43745),  
            (23800, 43744), (23803, 43741), (23804, 43739), (23806, 43738), 
            (23807, 43735), (23808, 43733), (23810, 43731), (23811, 43728), 
            (23813, 43724), (23816, 43721), (23819, 43715), (23820, 43712), 
            (23822, 43709), (23823, 43705), (23828, 43700), (23830, 43696), 
            (23837, 43686), (23839, 43682), (23846, 43675), (23848, 43670), 
            (23851, 43666), (23853, 43662), (23856, 43659), (23860, 43654), 
            (23862, 43650), (23866, 43648), (23871, 43640), (23874, 43634), 
            (23877, 43632), (23878, 43630), (23880, 43628), (23881, 43625), 
            (23883, 43621), (23889, 43618), (23890, 43616), (23892, 43614), 
            (23903, 43614), (23907, 43615), (23908, 43616), (23909, 43618), 
            (23911, 43618), (23911, 43619), (23912, 43619), (23912, 43620), 
            (23913, 43621), (23913, 43623), (23914, 43625), (23914, 43626), 
            (23917, 43632), (23917, 43688), (23916, 43689), (23916, 43693), 
            (23914, 43695), (23914, 43698), (23913, 43700), (23913, 43770)]

im[location] = 4
我得到以下回溯:

IndexError                                Traceback (most recent call last)
<ipython-input-6-2fb0def4341d> in <module>()
----> 1 arr[location] = 4

IndexError: index 43770 is out of bounds for axis 0 with size 37550
索引器错误回溯(最近一次调用)
在()
---->1 arr[位置]=4
索引器错误:索引43770超出大小为37550的轴0的界限
为什么这不起作用,为什么它认为43770 in(2391343770)应该沿着轴0?我尝试了反转元组,但我得到了相同的错误。我是否遗漏了一些明显的东西?

而不是
(x,y)
对(即
[(x1,y1),(x2,y2),…])
,您需要传递类似
[(x1,x2,…,(y1,y2,…])
。这也不是我所期望的(见类似问题)。就是用拉链。关于你的问题:

im[tuple(zip(*location))] = 4
给出您正在寻找的结果