0
#Each element of the FeatureFolds and ClassesFolds is a matrex by itself
#the classes are 5000x1 each
#the features are 5000 by 800 each


def FindAllVectors(c):


testC= c
FeatureFolds = [f1, f2 ,f3 ,f4 ,f5 ,f6 ,f7 ,f8 ,f9 ,f10]
ClassesFolds = [f1c ,f2c ,f3c ,f4c ,f5c ,f6c ,f7c ,f8c ,f9c ,f10c]
arr = np.array([])
for x in range(0,10):
    for y in range(0,5000):
        if (ClassesFolds[x][y][0]== testC):
            if (arr == []):
                arr = np.array(FeatureFolds[x][y]) 
            else:

                arr = np.append((arr, np.array(FeatureFolds[x][y])))

d= arr.shape
return d

returns an error: TypeError: append() takes at least 2 arguments (1 given) Could anyone explain why?

And append does not add it as a new row?How could I fix that?

ylish
  • 11
  • 1
  • 3
  • Well the error is pretty clear, you've passed a single arg, it looks like you have extraneous parentheses: `arr = np.append((arr, np.array(FeatureFolds[x][y])))` should be `arr = np.append(arr, np.array(FeatureFolds[x][y]))` – EdChum Mar 26 '15 at 21:35
  • Perhaps earlier you did `import numpy as np`, and maybe `numpy`'s `append()` takes two arguments, so the single argument `(arr, np.array(FeatureFolds[x][y]))` is insufficient? – TigerhawkT3 Mar 26 '15 at 21:36

1 Answers1

2

Your append line is passing a single param of a tuple rather than 2 arrays:

arr = np.append((arr, np.array(FeatureFolds[x][y])))
               #^- extraneous (  another one here -^

should be

arr = np.append(arr, np.array(FeatureFolds[x][y]))
EdChum
  • 376,765
  • 198
  • 813
  • 562
  • Use `vstack`: `arr = np.vstack([arr, np.array(FeatureFolds[x][y])])` see related: http://stackoverflow.com/questions/3881453/numpy-add-row-to-array – EdChum Mar 26 '15 at 21:40
  • What can I replace for append so that the FeatureFolds[x][y] is added as a new row? – ylish Mar 26 '15 at 21:41
  • Vstack throws back : ValueError: all the input array dimensions except for the concatenation axis must match exactl PS:Have to wait 5 min to accept it – ylish Mar 26 '15 at 21:43
  • Please post another question then, as that is a different issue to this one, also you should post data that reproduces your problem – EdChum Mar 26 '15 at 21:44