0

I want to append my numpy.array files. So I made code but it has error

I want to append by this code below. This form works well.

but the problem occur with using for loop

coordi_1 = mix(coord_0, coord_1, axis=0)

coordi_2 = mix(coord_1, coord_2, axis=0)

coordi_3 = mix(coord_2, coord_3, axis=0)

for i in range(0,191):

    coord_i = np.load(''+st[i].id+'.npy')
    print(coord_i)
    if i == 0:
        continue
    else:
        coordi_i = mix(coord_i-1, coord_i, axis=0)

The error massage is

ufunc 'subtract' did not contain a loop with signature matching types dtype('<U7') dtype('<U7') dtype('<U7')

and there is another code

for i in range(0,7941):

    if cola[i,1] == '':

        cola=np.delete(cola, i, axis=0)    

        i = i-1

I want to apply i-1 because after the one row is deleted,

This array miss a row next to the deleted row in loop.

so, If cola[i,1] == '', the i has to again or next i has to be -1.

What should I do?

shriakhilc
  • 2,922
  • 2
  • 12
  • 17
CUJeong
  • 7
  • 2
  • Since you are looping on `range(0, 7941)`, incrementing or decrementing `i` will have no effect. It will take the next element in the range. To get an equivalent reverse range, you can do `range(7940, -1, -1)`. The last `-1` is the `step`, which indicates difference between each iter. The first two are `start` and `end` (non-inclusive) as usual. – shriakhilc May 31 '19 at 10:27
  • 2
    Possible duplicate of [Loop backwards using indices in Python?](https://stackoverflow.com/questions/869885/loop-backwards-using-indices-in-python) – shriakhilc May 31 '19 at 10:30

0 Answers0