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?

2
  • 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])) Commented Mar 26, 2015 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? Commented Mar 26, 2015 at 21:36

1 Answer 1

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]))
Sign up to request clarification or add additional context in comments.

4 Comments

Use vstack: arr = np.vstack([arr, np.array(FeatureFolds[x][y])]) see related: stackoverflow.com/questions/3881453/numpy-add-row-to-array
What can I replace for append so that the FeatureFolds[x][y] is added as a new row?
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
Please post another question then, as that is a different issue to this one, also you should post data that reproduces your problem

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.